Created
April 29, 2025 15:31
-
-
Save antoineMoPa/efd5c68b51db6991abf01e3f972a67db to your computer and use it in GitHub Desktop.
Put this search script file in some dir that's in your PATH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -lt 1 ]; then | |
echo "Usage: $0 <search_pattern>" | |
echo " Searches for pattern in file contents and filenames" | |
exit 1 | |
fi | |
search_pattern=$1 | |
echo "=== 10 matches in file contents ===" | |
ag "$search_pattern" --nogroup | head -n 10 | |
echo "" | |
echo "=== 10 matching filenames ===" | |
ag -g "$search_pattern" | head -n 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment