Skip to content

Instantly share code, notes, and snippets.

@claudius108
Last active June 8, 2024 06:14
Show Gist options
  • Save claudius108/27ceb3fc26e3a362d046b26fd5410f2b to your computer and use it in GitHub Desktop.
Save claudius108/27ceb3fc26e3a362d046b26fd5410f2b to your computer and use it in GitHub Desktop.
Grep

Find recursively files containing multiline string

grep -Pazor --include="A*.xml" 'string.*\n.*string' .

Find recursively files containing string

grep -ril --include="A*.xml" "string" .

Find recursively files NOT containing string

grep -riL --include="A*.xml" "string" .

Filter twice some files and replace string

grep -rl "$email" "$citations_dir" | while read n; do grep -l "corrected" "$n"; done | xargs sed -i 's/"redactor"/"former-redactor"/g'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment