Skip to content

Instantly share code, notes, and snippets.

@foemre
Created November 24, 2022 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foemre/8d1c9b1f506e780ddf665d664e2be02b to your computer and use it in GitHub Desktop.
Save foemre/8d1c9b1f506e780ddf665d664e2be02b to your computer and use it in GitHub Desktop.
find text files that contain a regex pattern, extract the file basename, remove all files with that basename
grep -rw *.txt -e "^77" | cut -d'.' --complement -f2- | awk '!seen[$0]++' | while read line; do rm "$line".*; done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment