Skip to content

Instantly share code, notes, and snippets.

@gautam-nutalapati
Created May 16, 2023 14:54
Show Gist options
  • Save gautam-nutalapati/d5c6c0acae841f38372965e8fa6b3818 to your computer and use it in GitHub Desktop.
Save gautam-nutalapati/d5c6c0acae841f38372965e8fa6b3818 to your computer and use it in GitHub Desktop.
Bash Useful Search Commands (to manage bulk git repositories)
# Find multiple texts in all files under current directory
grep -rns '.' -e 'text-1' -e 'text-2'
# Find text 'text-1' in files of name 'ci.yaml' under current directory
grep -rns '.' -e 'text-1' --include=ci.yaml
# Find text 'text-1' in files of name 'ci.yaml' under current directory and pring 2 lines after the text found
# (-B for lines before and -C for both above and below)
grep -rns '.' -e 'text-1' --include=ci.yaml -A 2
# Go to all subdirectories in current directory and execute comamnds 'pwd' AND 'git status'
find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && pwd && git status" \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment