1、字符串处理,
请编写脚本code1.sh,要求输入逗号隔开的若干个名字,每个名字单独输出hello名字,how are you
例子:
输入 sh code1.sh perter,ken,zoe
则输出
hello peter,how are you!
hello ken,how are you!
hello zoe,how are you!
脚本功能如下
#!/bin/bash
nf=`echo "$1" | awk -F, '{print NF}'` for i in `seq 1 $nf` do a=`echo $1 | cut -d ',' -f $i` echo hello $a,How are you! done
执行结果如下
[root@localhost opt]# sh b.sh perter,jenkins,tom hello perter,How are you! hello jenkins,How are you! hello tom,How are you!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。