求助,shell合并
#!/bin/bash
Today=`date +%Y-%m-%d`
echo `date` > /home/log/$Today.txt
find /home/aa/test/ -type f -mtime -3 | xargs grep -l "12" | xargs -i echo {} > /home/log/$Today.txt
find /home/aa/test/ -type f -mtime -3 | xargs grep -l "12" | xargs -i mv {} /home/aa/test1
echo `date` > /home/log/$Today.txt
各位,红色标记的部分能否写成一句?或者简化?TKS
shell 合并
[解决办法]
#!/bin/bash
Today=`date +%Y-%m-%d`
date > /home/log/$Today.txt
for file in `find /home/aa/test/ -type f -mtime -3`; do
grep -q "12" $file
if [ $? == 0 ]; then
echo $file > /home/log/$Today.txt
mv $file /home/aa/test1
fi
done