码迷,mamicode.com
首页 > 系统相关 > 详细

数学之路-分布式计算-linux/unix技术基础(5)

时间:2014-09-19 12:10:35      阅读:263      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   ar   for   sp   log   

shell的命令行参数

-bash-4.2$ cat test1.sh
#!/bin/sh
echo "$0  "
echo "$1  "
echo "$2  "


-bash-4.2$ ./test1.sh a b c
./test1.sh  
a  
b  
-bash-4.2$ 

本博客所有内容是原创,如果转载请注明来源

http://blog.csdn.net/myhaspl/


显示所有命令行参数

-bash-4.2$ cat test1.sh
#!/bin/sh
until [ -z "$1" ]
do
   echo "$1  "
   shift
done
-bash-4.2$ ./test1.sh a b c d e f
a  
b  
c  
d  
e  

-bash-4.2$ cat test1.sh
#!/bin/sh
index=1
for myarg in $*
do
   echo "NO#$index=$myarg"
   let "index+=1"
done
-bash-4.2$ ./test1.sh a b c d e f
NO#1=a
NO#2=b
NO#3=c
NO#4=d
NO#5=e
NO#6=f
-bash-4.2$ 

数学之路-分布式计算-linux/unix技术基础(5)

标签:style   blog   http   color   io   ar   for   sp   log   

原文地址:http://blog.csdn.net/myhaspl/article/details/39394685

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!