Skip to content

Instantly share code, notes, and snippets.

@mrmurphy
Created May 27, 2016 16:45
Show Gist options
  • Save mrmurphy/10793df34e520f8cc9e5e1a0bbdb48d4 to your computer and use it in GitHub Desktop.
Save mrmurphy/10793df34e520f8cc9e5e1a0bbdb48d4 to your computer and use it in GitHub Desktop.
Insert a line at the beginning of files matching search pattern
# Requires siver-searcher to be installed
FILES=$(ag "<search term here, can be regex>" -l --js)
for i in $FILES; do
echo -e "<stuff to prepend here>\n$(cat $i)" > $i
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment