Write to multiple files...one command
Here is the first type of job I have had to do where I am making additions to multiple files, and I was wondering what the best way to go about it is.
I have to write the same lines to multiple file, too many to do it manually. The directory structure is this (directory names have been changed to protect the innocent): /usr/local/abc/abc_1/file /user/local/abc/abc_2/file /usr/local/abc/abc_3/file ... ... .. I want to make the same entry into "file" for all of files under "abc/abc_*/". What would be the best and safest command to accomplish this? |
You can try a for loop using the find command to list them, and edit the files one at a time. Or if you have simply to append some lines you can use tee, like this
Code:
echo line to append | tee /usr/local/abc/abc_?/file > /dev/null |
Quote:
Code:
echo line to append | tee -a /usr/local/abc/abc_?/file > /dev/null |
Yes, I had it in mind. Just forgotten. Thanks, pwc101 :)
|
All times are GMT -5. The time now is 12:39 PM. |