练习 2、写一个脚本/root/bin/yesorno.sh,提示用户输入yes或no,并判断用户输入的是yes还是no,或是其它信息 #!/bin/bash # case $1 in yY]|[yY][eE][Ss]) echo "you put a $1" ;; [nN]|[nN][Oo]) echo "you put a $1" ;; *) echo "ukown" ;; esac esca 3、写一个脚本/root/bin/filetype.sh,判断用户输入文件路径,显示其文件类型(普通,目录,链接,其它文件类型) #!/bin/bash # read -p "please input a file" FILE if [ -h $FILE ] ; then echo "filetype is symolink file" elif [ -d $FILE ] ;then echo "filetype is directory" elif [ -f $FILE ] ;then echo "common file." else echo "filetype is other" fi 4、写一个脚本/root/bin/checkint.sh,判断用户输入的参数是否为正整数 #!/bin/bash # if [[ $1 =~ ^0*[1-9][0-9]*$ ]] ;then echo "you have input a zhengshu" else echo "wrong" fi
shell脚本练习基础篇2
原创
©著作权归作者所有:来自51CTO博客作者powerlife的原创作品,谢绝转载,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Linux练习题-shell脚本编程基础篇
Linux练习题
Linux学习 shell脚本 -
Shell脚本初级练习篇
8个简单的shell脚本
脚本 shell -
centos 脚本基础练习2
自学小马哥linux 初级运维 练习
centos 练习 linux