在排查日志中可能会遇到查找某个目录下的所有文件是否包括某一内容,将自己在用的一个脚本贴出来,欢迎大家批评指正。
# batch.sh
# ========
#!/bin/bash
function read_dir(){
for file in `ls $1`
do
if [ -d $1"/"$file ]
then
read_dir $1"/"$file
else
grep 08S01 $1"/"$file #处理文件,包括但不限于grep,cat,echo等
fi
done
}
read_dir $1
执行文件
bash btch.sh [some dictionary]