我正在做一个搜索带有年龄的日志文件的scipt,并比较谁在日志中有一串文本,如果继续创建一个函数是正确的,但不受影响。我感谢任何建议或帮助
#!/bin/bash
file= find /AUX/backup/log/ -iname "*.log" -daystart -type f -mtime 1
if cat $file | grep -qw “INF - Status = completed."
then
echo "there is OK"
else
echo "there is KO"
fi
答案 0 :(得分:0)
#!/bin/bash
file=`find /AUX/backup/log/ -iname "*.log" -daystart -type f -mtime 1`
if grep -qw “INF - Status = completed." < $file
then
echo "there is OK"
else
echo "there is KO"
fi