当前位置: 技术问答>linux和unix
求助,shell合并
来源: 互联网 发布时间:2017-04-30
本文导语: #!/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 {} /...
#!/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
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
|
#!/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