- 在 Linux 下,任意一個命令執行結束之后,bash都會返回0-255之間的數值以表示命令執行成功與否;其返回值保存于bash的特殊變量$?中
- [root@yinwei tmp]# uptime
15:13:27 up 18 min, 1 user, load average: 0.07, 0.03, 0.05
[root@yinwei tmp]# echo $?
0
[root@yinwei tmp]# uptime.
-bash: uptime.: command not found
[root@yinwei tmp]# echo $?
127
[root@yinwei tmp]#
- bash的工作特性之命令行展開:
- bash中命令行展開主要有兩種:
- (1)~:自動展開為用戶的家目錄,或指定的用戶的家目錄;
- [root@yinwei tmp]# pwd
/tmp
[root@yinwei tmp]# cd ~
[root@yinwei ~]# pwd
/root
[root@yinwei ~]# - (2){}:可承載一個以逗號分隔的路徑列表,并能夠將其展開為多個路徑;
- [root@yinwei ~]# ls /tmp/test/*
ls: cannot access /tmp/test/*: No such file or directory
[root@yinwei ~]# mkdir -p /tmp/test/{a,b}
[root@yinwei ~]# ls -d /tmp/test/*
/tmp/test/a /tmp/test/b
[root@yinwei ~]#
本文來自投稿,不代表Linux運維部落立場,如若轉載,請注明出處:http://www.www58058.com/98775