Created
November 12, 2018 07:00
-
-
Save vitonzhangtt/cd92378c005d8e70973bef0e2849f37b to your computer and use it in GitHub Desktop.
Find target string from the files that name match the expression.
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 [ $# -ne 3 ]; then | |
echo "The number of arguments must be 3" | |
exit 1 | |
else | |
echo "Finding..." | |
fi | |
DIRECTORY=$1 | |
NAME=$2 | |
TARGET_STRING=$3 | |
echo $DIRECTORY | |
echo $NAME | |
echo $TARGET_STRING | |
echo ==================================== | |
FILES=`find $DIRECTORY -type f -name "$NAME"` | |
#echo $FILES | |
for file in $FILES; do | |
echo "starting scanning ${file}" | |
cat -n $file | grep ${TARGET_STRING} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment