Last active
October 28, 2020 15:32
-
-
Save akccakcctw/6db2fdebfc009e80bd8304e41aeaf2bc to your computer and use it in GitHub Desktop.
確認 string 在 project 內是否存在
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 | |
set -e | |
helpFunction() { | |
echo "" | |
echo "Usage: $0 -f file_path -o output_path" | |
echo -e "\t-f file path" | |
echo -e "\t-o output path" | |
exit 1 | |
} | |
while getopts "f:o:" opt | |
do | |
case "$opt" in | |
f ) filePath="$OPTARG" ;; | |
o ) outputPath="$OPTARG" ;; | |
? ) helpFunction ;; | |
esac | |
done | |
# start | |
cnt=0 | |
while read -r line; do | |
cnt=$(( cnt + 1 )) | |
echo -ne "testing $cnt case... \r" | |
if ! rg -q "('|\")$line('|\")" < /dev/null; | |
then | |
# not found (exit code !== 0) | |
echo "$line" >> "$outputPath" | |
fi | |
done < "$filePath" | |
echo "done. " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment