Find files with ack and replace string with sed

ack is a nice to tool to search in files in your current directory and subdirectores, but ack won't do search and replace. Luckily, we can easily combine ack and sed using xargs.

ack -l " myapp" | xargs sed -i 's| myapp| "{{ }}"|g'

This example searches for the string myapp through all files and subdirs from current directory and tell ack to only output file names with the -l option. Then we use xargs to append the filename to the end of the sed command.