Skip to content

Instantly share code, notes, and snippets.

@mkrogemann
Created September 6, 2018 14:30
Show Gist options
  • Select an option

  • Save mkrogemann/a649357ba7089c4b01d88bcde67fedd5 to your computer and use it in GitHub Desktop.

Select an option

Save mkrogemann/a649357ba7089c4b01d88bcde67fedd5 to your computer and use it in GitHub Desktop.
This little shell script will walk through a directory hierarchy, find given text in matching files and remove the whole line in which the text appears
#!/bin/bash
for thefile in `find <path to start from> -type f -name <filename pattern>` ; do
grep -v "<text to be removed (affects whole line)>" $thefile > $thefile.$$.tmp
mv $thefile.$$.tmp $thefile
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment