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.

Revisions

  1. akccakcctw revised this gist Oct 28, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion check_string_exist_in_project.sh
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ helpFunction() {
    exit 1
    }

    while getopts "f:o:s:" opt
    while getopts "f:o:" opt
    do
    case "$opt" in
    f ) filePath="$OPTARG" ;;
  2. akccakcctw revised this gist Oct 28, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion check_string_exist_in_project.sh
    Original file line number Diff line number Diff line change
    @@ -27,7 +27,7 @@ while read -r line; do
    if ! rg -q "('|\")$line('|\")" < /dev/null;
    then
    # not found (exit code !== 0)
    echo "$line" >> "$outputPath"
    echo "$line" >> "$outputPath"
    fi
    done < "$filePath"
    echo "done. "
  3. akccakcctw revised this gist Oct 28, 2020. 1 changed file with 12 additions and 12 deletions.
    24 changes: 12 additions & 12 deletions check_string_exist_in_project.sh
    Original file line number Diff line number Diff line change
    @@ -3,20 +3,20 @@
    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
    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:s:" opt
    do
    case "$opt" in
    f ) filePath="$OPTARG" ;;
    o ) outputPath="$OPTARG" ;;
    ? ) helpFunction ;;
    esac
    case "$opt" in
    f ) filePath="$OPTARG" ;;
    o ) outputPath="$OPTARG" ;;
    ? ) helpFunction ;;
    esac
    done

    # start
    @@ -28,6 +28,6 @@ while read -r line; do
    then
    # not found (exit code !== 0)
    echo "$line" >> "$outputPath"
    fi
    fi
    done < "$filePath"
    echo "done. "
    echo "done. "
  4. akccakcctw revised this gist Oct 28, 2020. 1 changed file with 9 additions and 8 deletions.
    17 changes: 9 additions & 8 deletions check_string_exist_in_project.sh
    Original file line number Diff line number Diff line change
    @@ -4,9 +4,8 @@ set -e

    helpFunction() {
    echo ""
    echo "Usage: $0 -f file_path -s search_path -o output_path"
    echo "Usage: $0 -f file_path -o output_path"
    echo -e "\t-f file path"
    echo -e "\t-s search path"
    echo -e "\t-o output path"
    exit 1
    }
    @@ -16,17 +15,19 @@ do
    case "$opt" in
    f ) filePath="$OPTARG" ;;
    o ) outputPath="$OPTARG" ;;
    s ) searchPath="$OPTARG" ;;
    ? ) helpFunction ;;
    esac
    done

    # start
    while IFS= read -r line; do
    which rg
    if rg -q "$line" "$searchPath"; then
    true
    else
    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. "
  5. akccakcctw created this gist Oct 28, 2020.
    32 changes: 32 additions & 0 deletions check_string_exist_in_project.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    #!/usr/bin/env bash

    set -e

    helpFunction() {
    echo ""
    echo "Usage: $0 -f file_path -s search_path -o output_path"
    echo -e "\t-f file path"
    echo -e "\t-s search path"
    echo -e "\t-o output path"
    exit 1
    }

    while getopts "f:o:s:" opt
    do
    case "$opt" in
    f ) filePath="$OPTARG" ;;
    o ) outputPath="$OPTARG" ;;
    s ) searchPath="$OPTARG" ;;
    ? ) helpFunction ;;
    esac
    done

    # start
    while IFS= read -r line; do
    which rg
    if rg -q "$line" "$searchPath"; then
    true
    else
    echo "$line" >> "$outputPath"
    fi
    done < "$filePath"