Created
July 29, 2022 18:55
-
-
Save codenamev/ff1d72a6f2238d97173d029116fa27be to your computer and use it in GitHub Desktop.
Search files for line
This file contains 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
#!/usr/bin/env bash | |
# usage: file-contains-in-x-lines matchy path/to/file | |
# Check if single file contains "matchy" in the first 10 lines | |
head -n 10 $2 | grep -m 1 $1 |
This file contains 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
#!/usr/bin/env bash | |
# usage: find-files-matching-line matchy . | |
# Find files that contain "matchy" in the first 10 lines | |
grep -m 1 -n $1 $2 -H | awk -F'[:]' '{if($2 <= 10) print($1) }' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment