<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 練習 9:Bash:任務控制,`jobs`,`fg` > 原文:[Exercise 9. Bash: job control, jobs, fg](https://archive.fo/z1oWk) > 譯者:[飛龍](https://github.com/wizardforcel) > 協議:[CC BY-NC-SA 4.0](http://creativecommons.org/licenses/by-nc-sa/4.0/) > 自豪地采用[谷歌翻譯](https://translate.google.cn/) Linux是一個[多任務](http://en.wikipedia.org/wiki/Computer_multitasking)操作系統。這意味著有許多程序同時運行。從用戶的角度來看,這意味著你可以同時運行幾個程序,而且 bash 肯定有工具,為你控制多個任務的執行。為了能夠使用此功能,你需要學習以下命令: + `<CTRL> + z` - 將當前運行的程序放在后臺。 + `jobs` - 列出所有后臺程序。 + `fg` - 把程序帶到前臺。`fg`接受一個數字作為參數,它可以從`jobs`中獲取數,或者如果無參數調用,則將最后一個掛起的程序帶到前臺。 + `ctrl + c` - 一次性停止執行當前運行的程序。雖然我不會在這個練習中使用它,但我必須說,這可能是非常有用的。 現在,你將學習如何使用 bash 內置的工具來控制程序的執行。 ## 這樣做 ``` 1: less -S .profile 2: <CTRL+z> 3: less -S .bashrc 4: <CTRL+z> 5: less -S .bash_history 6: <CTRL+z> 7: jobs 8: fg 9: q 10: fg 11: q 12: fg 13: q 14: fg 15: jobs ``` ## 你會看到什么 ``` user1@vm1:~$ less -S .profile # exists. # see /usr/share/doc/bash/examples/startup-files for # the files are located in the bash-doc package. # the default umask is set in /etc/profile; for setti # for ssh logins, install and configure the libpam-um #umask 022 # if running bash if [ -n "$BASH_VERSION" ]; then # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc" [1]+ Stopped less -S .profile user1@vm1:~$ less -S .bashrc # for examples # If not running interactively, don't do anything [ -z "$PS1" ] && return # don't put duplicate lines in the history. See bash( # don't overwrite GNU Midnight Commander's setting of HISTCONTROL=$HISTCONTROL${HISTCONTROL+:}ignoredups # ... or force ignoredups and ignorespace HISTCONTROL=ignoreboth # append to the history file, don't overwrite it shopt -s histappend [2]+ Stopped less -S .bashrc user1@vm1:~$ less -S .bash_history echo Hello, $LOGNAME! echo 'echo Hello, $LOGNAME!' >> .profile cp .profile .profile.bak tail .profile ls -altr history -w ls -al cat .profile echo Hello, $LOGNAME! echo 'echo Hello, $LOGNAME!' >> .profile cp .profile .profile.bak tail .profile ls -altr [3]+ Stopped less -S .bash_history user1@vm1:~$ jobs [1] Stopped less -S .profile [2]- Stopped less -S .bashrc [3]+ Stopped less -S .bash_history user1@vm1:~$ fg user1@vm1:~$ fg user1@vm1:~$ fg user1@vm1:~$ fg -bash: fg: current: no such job user1@vm1:~$ jobs user1@vm1:~$ ``` ## 解釋 1. 打開`.profile`來查看。注意我如何使用`-S`參數,讓`less`開啟`-chop-long-lines`選項來啟動。 1. 掛起`less`。 1. 打開`.bashrc`來查看。 1. 掛起`less`。 1. 打開`.bash_history`來查看。 1. 掛起`less`。 1. 打印掛起程序的列表。 1. 切換到`less`。 1. 退出它。 1. 切換到第二個`less`。 1. 退出它。 1. 切換到第一個`less`。 1. 退出它。 1. 嘗試切換到最后一個程序。沒有任何程序,但你這樣做是為了確保確實沒有。 1. 打印掛起程序的列表。這是為了確保沒有后臺任務,通過看到`jobs`打印出空的輸出。 ## 附加題 打開`man bash`,搜索 JOB CONTROL,輸入`/, JOB CONTROL, <ENTER>`,并閱讀它。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看