我继承了一位前员工的代码,我需要识别他使用顶部的 exit 0
禁用的脚本。
如果我这样做 head -2 load_db.ksh |尾部-1 | grep hello
在脚本上,效果很好。我在脚本的第二行看到了 exit 0
语句。
如何自动化处理近 900 个脚本?我尝试使用 find 但它出错了
find . -name "*.ksh" -exec head -2 '{}' | tail -1 |grep exit \;
grep: ;: No such file or directory
find: missing argument to -exec
我找不到语法错误。
最佳答案
您当前正在将 find 的输出定向到 tail,请尝试以下操作:
find . -name "*.ksh" -exec sh -c "head -2 '{}' | tail -1 | grep exit" \;
关于unix - 解析一个字符串的 1000 个脚本的最佳方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23637824/