1、作業控制技巧 Bash環境中通過命令運行一個進程的時候,使【&】 符可以使改進程進入後臺 (base) [root@localhost ~]# sh test.sh & [1] 46963 (base) [root@localhost ~]# 將該進程放入後臺並暫停執行 Ctrl+z (base ...
1、作業控制技巧
Bash環境中通過命令運行一個進程的時候,使【&】 符可以使改進程進入後臺
(base) [root@localhost ~]# sh test.sh & [1] 46963 (base) [root@localhost ~]#
將該進程放入後臺並暫停執行 Ctrl+z
(base) [root@localhost ~]# sh test.sh ^Z ---(Ctrl + Z) [2]+ Stopped sh test.sh (base) [root@localhost ~]# jobs [1]- Stopped sh test.sh [2]+ Stopped sh test.sh (base) [root@localhost ~]#
查看後臺進程命令 jobs
(base) [root@localhost ~]# jobs [1]+ Running sh test.sh & (base) [root@localhost ~]#
通過fg(編號) 的形式可以將這些後臺進程再次調入前臺執行
(base) [root@localhost ~]# fg 1 sh test.sh
2、花括弧{}的使用
可以通過括弧 擴展 生成 命令行和腳本需要是字元串。
括弧可以包含連續的序列或使用逗號分割的多個項目。連續的序列包含一個起點和一個終點,並使用“”..“”分割。
例子如下:
(base) [root@localhost ~]# echo {a,b,c} a b c (base) [root@localhost ~]# echo user{1,5,6} user1 user5 user6 (base) [root@localhost ~]# echo {0..10} 0 1 2 3 4 5 6 7 8 9 10 (base) [root@localhost ~]# echo a{2..-1} a2 a1 a0 a-1 (base) [root@localhost ~]# mkdir /tmp/{dir1,dir2,dir3} (base) [root@localhost ~]# ls -ld /tmp/dir{1,2,3} drwxr-xr-x. 2 root root 6 May 23 23:31 /tmp/dir1 drwxr-xr-x. 2 root root 6 May 23 23:31 /tmp/dir2 drwxr-xr-x. 2 root root 6 May 23 23:31 /tmp/dir3 (base) [root@localhost ~]# chmod 777 /tmp/dir{1,2,3} (base) [root@localhost ~]# ls -ld /tmp/dir{1,2,3} drwxrwxrwx. 2 root root 6 May 23 23:31 /tmp/dir1 drwxrwxrwx. 2 root root 6 May 23 23:31 /tmp/dir2 drwxrwxrwx. 2 root root 6 May 23 23:31 /tmp/dir3 (base) [root@localhost ~]#