编写shell脚本,将/usr/local/test目录下大于100k的文件转移到/tmp目录下:
#!/bin/bash
for FILE in `ls /usr/local/test`
do
if [ -f $FILE ] ; then
if [ `ls -l $FILE | awk `{print $5}` -gt 100000 ] ; then
mv $FILE /tmp/
fi
fi
done
================
#!/bin/bash
for FileName in `ls -l /usr/local/test | awk '$5>102400' {print $9}`
do
mv $FileName /tmp/
done
ls -al /tmp/
echo "done!"
#!/bin/bash
for FILE in `ls /usr/local/test`
do
if [ -f $FILE ] ; then
if [ `ls -l $FILE | awk `{print $5}` -gt 100000 ] ; then
mv $FILE /tmp/
fi
fi
done
================
#!/bin/bash
for FileName in `ls -l /usr/local/test | awk '$5>102400' {print $9}`
do
mv $FileName /tmp/
done
ls -al /tmp/
echo "done!"
编辑回复