标签:$? $$ $* $@
一条命令创建月份的每一天
[root@localhost work]# mkdir $(echo {20150101..20150131})
[root@localhost work]# ls
20150101 20150104 20150107 20150110 20150113 20150116 20150119 20150122 20150125 20150128 20150131
20150102 20150105 20150108 20150111 20150114 20150117 20150120 20150123 20150126 20150129
20150103 20150106 20150109 20150112 20150115 20150118 20150121 20150124 20150127 20150130
[root@localhost work]# mkdir {20150201..20150230}
[root@localhost work]# ls
20150201 20150204 20150207 20150210 20150213 20150216 20150219 20150222 20150225 20150228
20150202 20150205 20150208 20150211 20150214 20150217 20150220 20150223 20150226 20150229
20150203 20150206 20150209 20150212 20150215 20150218 20150221 20150224 20150227 20150230
dirname命令显示路径名称
[root@localhost work]# dirname /root/.bash_profile
/root
basename命令显示文件名称
[root@localhost work]# basename /root/.bash_profile
.bash_profile
$? 获取执行上一个命令的返回值(0为成功,非0为失败),返回值参考
0 运行成功
2 权限拒绝
1~125 运行失败,脚本命令,系统命令错误或参数传递错误
126 找到命令,但无法运行
127 未找到运行的命令
>128 命令被系统强制结束
$$ 获取当前执行命令的进程号PID
$* 将命令行所有参数视为单个字符串,等同于“$!$2$3”
$@ 将命令行每个参数视为单独的字符串,等同于“$1” “$2” “$3” ,这是将参数传递给其他程序的最佳方式,它会保留所有内嵌在每个参数领的任何空白。
本文出自 “夏云静涌” 博客,请务必保留此出处http://791557234.blog.51cto.com/3428771/1673272
标签:$? $$ $* $@
原文地址:http://791557234.blog.51cto.com/3428771/1673272