Nitesh
Nitesh

Reputation: 11

How to append a file to multiple files in shell?

I have a TXT file that I need to append at the bottom of multiple files. I'm currently using for loop for that :

for file in file1 file2; do cat footer.txt >> $file; done

Any other commands I can use instead?

Upvotes: 0

Views: 351

Answers (1)

plbogen
plbogen

Reputation: 61

The tee command allows you to apply changes to several files at once.

tee -a file1 file2 < footer.txt

Will do it. The -a tells tee to append on the end.

Upvotes: 3

Related Questions