歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux技術 >> lixux系統中bash命令下一些操作技巧 學會後可事半功倍

lixux系統中bash命令下一些操作技巧 學會後可事半功倍

日期:2017/3/1 17:56:58   编辑:Linux技術

  tab鍵補全用法

  當我們敲擊一下tab補全命令或文件名

  當我們敲擊兩下tab 列出相關的所有可選項

  cd - 相當於電視的回看

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

  查看以下例子

  [root@localhost /]# cd /tmp

  [root@localhost tmp]# pwd

  /tmp

  [root@localhost tmp]# cd /

  [root@localhost /]# pwd

  /

  [root@localhost /]# cd -

  /tmp

  [root@localhost tmp]# pwd

  /tmp

  Esc+.

  用法舉例

  首先touch一個文件,然後編輯這個文件

  touch abcdefghijk

  敲入vi ,然後Esc+. 發現是不是abcdefghijk已經出現在vi後面\

   轉義字符用法

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

  查看系統別名可以使用alias命令,例如以下系統默認的別名。

  [root@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'

  有時候我們刪一個文件時候,會出現以下提示, 需要我們一個個確認,原因就是rm默認就是rm -i起了作用。

  [root@localhost testdir]# cd dir1

  [root@localhost dir1]# ls

  file1 file2 file3 file4

  [root@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

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

  [root@localhost testdir]# cd dir1

  [root@localhost dir1]# ls

  file1 file2 file3 file4

  [root@localhost dir1]# \rm file1 file2 file3 file4

Copyright © Linux教程網 All Rights Reserved