search.sh
#!/usr/bin/env bash #SELFDIR=$(dirname $(realpath "$BASH_SOURCE")) #grep --exclude Defines.h Truthtable.h * SELFDIR=$(cd $(dirname "$BASH_SOURCE");pwd) if [[ ${SELFDIR} == "" ]]; then echo "Internal error: can not locate the script dir" exit 1 fi echo $SELFDIR for file in `ls $SELFDIR` do if ( grep $1 $file );then echo $file fi done运行:bash search.sh whatIwantFind
#!/usr/bin/env bash #SELFDIR=$(dirname $(realpath "$BASH_SOURCE")) #grep --exclude Defines.h Truthtable.h * SELFDIR=$(cd $(dirname "$BASH_SOURCE");pwd) if [[ ${SELFDIR} == "" ]]; then echo "Internal error: can not locate the script dir" exit 1 fi echo $SELFDIR for file in `ls $SELFDIR` do if ( echo "$file:" && grep "delim" $file );then echo "" fi done上一篇:https://blog.csdn.net/wxkhturfun/article/details/108873997