Hi All,
Been trying to create a script that will delete lines from multiple files according to the contents of a template file but I can't seem to get it right.
I'm thinking of something like the above, could anyone help?
I think I also have to output the edits to a new file
but not sure how t go about this
Been trying to create a script that will delete lines from multiple files according to the contents of a template file but I can't seem to get it right.
Code:
file_location="/tmp/*"
template_file=bleh.txt
for file in $(ls -1 ${file_location})
do
for remove in $(cat ${template_file}
do
sed '/'${remove}'/d' ${file}
done
done
I'm thinking of something like the above, could anyone help?
I think I also have to output the edits to a new file
Code:
sed '/'${remove}'/d' ${file} >${file}_new
mv ${file}_new ${file}
Last edited: