I have one file that contain copyright notice, that I would like to append to all files in our directory structure (excluding binaries). How can I do that? Thanks for your help!
Use a loop like this:
for i in *.txt; do
cat copyrightfile "$i" > tempfile
mv tempfile "$i"
done
How do you determine whether a file is binary or not?
The following scripts assumes a command or function is_binary that tests the file. You need to supply that test.
cd /top/of/your/directory/structure
copyrightfile=/path/to/file
copyright=$( cat "$copyrightfile" )
find . -type f |
while IFS= read -r file
do
is_binary "$file" ||
printf "%s\n" "$copyright" >> "$file"
done
for i in `ls -l | grep ^- | awk '{print $9}'`
do
cat copyright.txt >> $i
done