Skip to content

Instantly share code, notes, and snippets.

@akccakcctw
Last active October 28, 2020 15:32
Show Gist options
  • Save akccakcctw/6db2fdebfc009e80bd8304e41aeaf2bc to your computer and use it in GitHub Desktop.
Save akccakcctw/6db2fdebfc009e80bd8304e41aeaf2bc to your computer and use it in GitHub Desktop.
確認 string 在 project 內是否存在
#!/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