帮忙写个简单的shell脚本

[复制链接]
查看11 | 回复5 | 2013-1-13 22:57:23 | 显示全部楼层 |阅读模式
[root@dba ~]# cat test.sh#!/bin/bashif [ `cat 1.txt` -eq 1 ] ; then
mv 2.txt 3.txt && echo "1 so 2 to 3" && exit;fiif [ `cat 1.txt` -eq 2 ] ; then
mv 3.txt 2.txt && echo "2 so 3 to 2" && exit;else
echo "nothing to do";fi实验1[root@dba ~]# cat 1.txt1[root@dba ~]# ls1.txttest.sh 2.txt...
回复

使用道具 举报

千问 | 2013-1-13 22:57:23 | 显示全部楼层
#!/usr/local/bin/bashnum=`sed -n '$=' /mnt/1/1.txt`//n为数字所在行数if [ $num -eq 1 ]; then mv /system/etc/2.txt /system/etc/3.txtelif [ $num -eq 2 ]; then mv /system/etc/3.txt...
回复

使用道具 举报

千问 | 2013-1-13 22:57:23 | 显示全部楼层
#!/bin/shif [ -f /mnt/1/1.txt ];then
if [ `cat /mnt/1/1.txt` -eq 1 ];then
if [ -f /system/etc/2.txt ];then
cd /system/etc/ ...
回复

使用道具 举报

千问 | 2013-1-13 22:57:23 | 显示全部楼层
vi test.sh#!/bin/bashif [ `cat 1.txt` -eq 1 ] ; then
mv 2.txt 3.txt && exit;fiif [ `cat 1.txt` -eq 2 ] ; then
mv 3.txt 2.txt && exit;else
echo "DO NOTHIN...
回复

使用道具 举报

千问 | 2013-1-13 22:57:23 | 显示全部楼层
#!/bin/bashexec 3</mnt/1/1.txtread -u 3 optioncase $option in"1")mv /system/etc/{2,3}.txt;;"2")mv /system/etc/{3,2}.txt;;*):echo "Do Nothing";;esac...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行