Skip to content

Instantly share code, notes, and snippets.

@brunneis
Created January 18, 2018 19:03
Show Gist options
  • Save brunneis/e9536495737c991a156bef145a08f984 to your computer and use it in GitHub Desktop.
Save brunneis/e9536495737c991a156bef145a08f984 to your computer and use it in GitHub Desktop.
Delete all files containing a string (for files with very long lines)
#!/bin/bash
SEARCH_PATH="."
MAX_CHARS_PER_FILENAME=50
grep -r "string" $SEARCH_PATH | cut -c 1-$MAX_CHARS_PER_FILENAME | cut -d ':' -f 1 | xargs rm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment