Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash, find, exec and echo

find . \
  -name 'user_prefs' \
  -exec echo "whitelist_from [email protected]" >> {} \;'

I would like to add the line whitelist_from [email protected] to all files that are found by find, but my command does not work. It just creates the file '{}'.

Shoud i use the for command?

thanks!

like image 235
Roberto Avatar asked Dec 17 '10 13:12

Roberto


1 Answers

You have to escape the '>>', for example like this:

find . -name 'user_prefs' -exec sh -c 'echo "whitelist_from [email protected]" >> {}' \;
like image 189
Balázs Pozsár Avatar answered Sep 30 '22 18:09

Balázs Pozsár