打印一个给定的数字的反序,如输入10572,输出27501
- #!/bin/bash
- if[ $# -ne 1 ]
- then
- echo "Usage: $0 number"
- echo " I will find reverse of given number"
- echo " For eg. $0 0123, I will print 3210"
- exit1
- fi
- n=$1
- rev=0
- sd=0
- while[ $n -gt 0]
- do
- sd=`expr $n % 10`
- rev=`expr $rev \* 10 + $sd`
- n=`expr $n / 10`
- done
- echo "Reverse number is $rev"
2、 将/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!"
时间: 2024-10-29 19:48:33