linux shell学习(一)第一个hello world

来源:互联网 发布:行知实践园自己感受 编辑:程序博客网 时间:2024/05/18 20:07
#!/bin/bash#we have less than 3 arguents# $#表示命令行参数的个数if [ $# -lt 3 ];then     # $*表示命令行参数    echo $* elif [ $# -eq 3 ];then    echo $*elif [ $# -gt 3 ];then    echo $*fi# file是在命令行参数中的循环for file in $*; do    # 判断file是否是目录中存在的文件    if [ -f "$file" ]; then        echo $file is exsit        #如果有两个参数,那么改名字        if [ $# -eq 2 ];then            mv "$1" "$2"        fi    fidone

结果:

rongtao@rongtao:~/shell$ sh Demo.sh Hello World !Hello World !rongtao@rongtao:~/shell$ 


阅读全文
0 0