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 ~]#
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/481127.html
標籤:Linux
上一篇:在U盤下安裝ubuntu20.04,從U盤啟動Linux系統
下一篇:Linux c 獲取U盤掛載路徑
