linux脚本问题,请帮忙写个脚本 rhce的考题
发布网友
发布时间:2022-03-01 22:41
我来回答
共5个回答
热心网友
时间:2022-03-02 00:11
需要的脚本如下:
# vi /root/program
#! /bin/bash
case $1 in
kernel )
echo user
;;
user )
echo kernel
;;
* )
echo 'usage:/root/program kernel | user'
;;
esac
测试结果如下:
[root@rhel4 ~]# chmod +x /root/program
[root@rhel4 ~]# /root/program kernel
user
[root@rhel4 ~]# /root/program user
kernel
[root@rhel4 ~]# /root/program
usage:/root/program kernel | user
[root@rhel4 ~]# /root/program hello
usage:/root/program kernel | user
[root@rhel4 ~]# /root/program *
usage:/root/program kernel | use
这应该就是你需要的吧。
热心网友
时间:2022-03-02 01:29
呵呵
vim /root/program
#/bin/bash
if[ “$1” == “kernel” ] ; then
echo “user”
elif [ “$1” == “user” ] ; then
echo “kernel”
else
echo “usage:/root/program kernel|user”
fi
chmod a+x /root/program
我就不具名了,你也明白的,有问题留言就可以,望采纳
热心网友
时间:2022-03-02 03:03
vim /root/program
#/bin/bash
if[ “$1” == “kernel” ] ; then
echo “user”
elif [ “$1” == “user” ] ; then
echo “kernel”
else
echo “usage:/root/program kernel|user”
fi
chmod a+x /root/program
热心网友
时间:2022-03-02 04:55
vim /root/program
#!/bin/bash
if [ $1 = "user" ] ; then
echo "kernel"
fi
if [ $1 = "kernel" ] ; then
echo "user"
fi
chmod 777 /root/program
参考资料:http://malu.me
热心网友
时间:2022-03-02 07:03
描述清楚些啊。。。