系統(tǒng)之家 - 系統(tǒng)光盤下載網(wǎng)站!

當(dāng)前位置:系統(tǒng)之家 > 系統(tǒng)教程 > Linux bash命令操作技巧

Linux初學(xué)者需了解的Bash命令操作技巧分享

時(shí)間:2014-12-11 15:24:09 作者:qipeng 來源:系統(tǒng)之家 1. 掃描二維碼隨時(shí)看資訊 2. 請使用手機(jī)瀏覽器訪問: https://m.xitongzhijia.net/xtjc/20141211/32382.html 手機(jī)查看 評論

  Bash是Bourne-Again SHell的縮寫,是許多Linux平臺內(nèi)定的shell,其實(shí)Bash命令有許多操作技巧,很多初學(xué)者可能還不知道,掌握這些技巧能夠更快的完成工作,一起來學(xué)習(xí)下吧。

 Linux初學(xué)者需了解的Bash命令操作技巧分享

  tab鍵補(bǔ)全用法

  當(dāng)我們敲擊一下tab補(bǔ)全命令或文件名

  當(dāng)我們敲擊兩下tab 列出相關(guān)的所有可選項(xiàng)

  cd - 相當(dāng)于電視的回看

  有時(shí)候我們進(jìn)入一個(gè)非常長的目錄,后來又進(jìn)入另一個(gè)目錄,可能我們還行回到原來那個(gè)長,如果事先知道,我們可能輸入pwd ,以便一會兒粘貼,有時(shí)候忘了輸入pwd我們可能無奈還得輸入一次長長的路徑,我們可以輸入一下cd -試試,直接回到上次進(jìn)入的目錄,就像是看電視時(shí)候的回看按鈕。是不是很好用?

  查看以下例子

 。踨oot@localhost /]# cd /tmp

  [root@localhost tmp]# pwd

  /tmp

 。踨oot@localhost tmp]# cd /

  [root@localhost /]# pwd

  /

 。踨oot@localhost /]# cd -

  /tmp

 。踨oot@localhost tmp]# pwd

  /tmp

  Esc+.

  用法舉例

  首先touch一個(gè)文件,然后編輯這個(gè)文件

  touch abcdefghijk

  敲入vi ,然后Esc+. 發(fā)現(xiàn)是不是abcdefghijk已經(jīng)出現(xiàn)在vi后面\

  轉(zhuǎn)義字符用法

  系統(tǒng)中一些命令都是別名的功能,比如我們使用的rm、mv等,實(shí)際上是 rm -i和mv -i 。

  查看系統(tǒng)別名可以使用alias命令,例如以下系統(tǒng)默認(rèn)的別名。

 。踨oot@localhost testdir]# alias

  alias cp=‘cp -i’

  alias egrep=‘egrep --color=auto’

  alias fgrep=‘fgrep --color=auto’

  alias grep=‘grep --color=auto’

  alias l.=‘ls -d .* --color=auto’

  alias ll=‘ls -l --color=auto’

  alias ls=‘ls --color=auto’

  alias mv=‘mv -i’

  alias rm=‘rm -i’

  alias which=‘alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde’

  有時(shí)候我們刪一個(gè)文件時(shí)候,會出現(xiàn)以下提示, 需要我們一個(gè)個(gè)確認(rèn),原因就是rm默認(rèn)就是rm -i起了作用。

 。踨oot@localhost testdir]# cd dir1

  [root@localhost dir1]# ls

  file1 file2 file3 file4

 。踨oot@localhost dir1]# rm file1 file2 file3 file4rm: remove regular empty file ?.ile1?。 y

  rm: remove regular empty file ?.ile2?。 y

  rm: remove regular empty file ?.ile3?。 y

  rm: remove regular empty file ?.ile4?。 y

  我們可以使用轉(zhuǎn)移字符使別名失效,使用如下,刪除就不會再有提示確認(rèn)了。

 。踨oot@localhost testdir]# cd dir1

  [root@localhost dir1]# ls

  file1 file2 file3 file4

 。踨oot@localhost dir1]# \rm file1 file2 file3 file4

  上面就是bash命令的操作技巧的介紹了,想要學(xué)的精,光掌握命令是不夠的,還要靈活應(yīng)用一些操作技巧,這樣才能事半功倍,你學(xué)會了嗎?

標(biāo)簽 命令 Bash

發(fā)表評論

0

沒有更多評論了

評論就這些咯,讓大家也知道你的獨(dú)特見解

立即評論

以上留言僅代表用戶個(gè)人觀點(diǎn),不代表系統(tǒng)之家立場

其他版本軟件

熱門教程

人氣教程排行

Linux系統(tǒng)推薦

官方交流群 軟件收錄