linux命令技巧

來源:互聯網
上載者:User

linux命令技巧
[oracle@rh64 ~]$ cat lgrw.txt cat: lgrw.txt: No such file or directory [oracle@rh64 ~]$ ^rw^wr cat lgwr.txt 18:03:19.703928 times({tms_utime=27, tms_stime=18, tms_cutime=0, tms_cstime=0}) = 433678186 18:03:19.704111 semtimedop(1900546, {{15, -1, 0}}, 1, {1, 660000000}) = -1 EAGAIN (Resource temporarily unavailable) 18:03:21.364682 getrusage(RUSAGE_SELF, {ru_utime={0, 278957}, ru_stime={0, 184971}, ...}) = 0 18:03:21.364760 getrusage(RUSAGE_SELF, {ru_utime={0, 278957}, ru_stime={0, 184971}, ...}) = 0
[oracle@rh64 ~]$ history --10 -bash: history: --: invalid option history: usage: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...] [oracle@rh64 ~]$ ^-- history 10 1002 ls -lte [oracle@rh64 ~]$ echo mount /dev/mapper/vg0-lv1 /data1 mount /dev/mapper/vg0-lv1 /data1 [oracle@rh64 ~]$ !:gs/1/2 echo mount /dev/mapper/vg0-lv2 /data2 mount /dev/mapper/vg0-lv2 /data2 [oracle@rh64 ~]$

引用命令列 ![!|[?]string|[-]number]
:[n|x-y|^|$|*|n*|%]:[h|t|r|e|p|s|g] -------選擇word---- ----修飾符-----
!! ---上一條命令 !cat 以cat開頭的命令 [oracle@rh64 ~]$ !cat cat /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin
!?cat 含cat的命令 [oracle@rh64 ~]$ !?cat cat /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nolog
!n 第 n 個命令 !-n 倒數第 n 個命令
!$ 上條命令最後一位
!^ 上條命令第一位
!:n 上條命令第 n 位
!:x-y 上條命令 x - y
!:n* 上條 n 到最後
!* 上條所有參數
:h 選取路徑開頭
:t 選取路徑結尾
:r 選取檔案名稱 [oracle@rh64 ~]$ echo a.txt a.txt [oracle@rh64 ~]$ !$:t a.txt -bash: a.txt: command not found [oracle@rh64 ~]$ echo !$:r echo a a :e 選取副檔名 [oracle@rh64 ~]$ echo abc.jpg abc.jpg [oracle@rh64 ~]$ echo !$:e echo .jpg .jpg
:p 列印命令列 [oracle@rh64 ~]$ !e:p echo .jpg [oracle@rh64 ~]
:s 做替換 % echo this that % !:s/is/e echo the that 慣用法: ^is^e [oracle@rh64 ~]$ echo this that this that [oracle@rh64 ~]$ !:s/is/e echo the that the that [oracle@rh64 ~]$ ^is^e -bash: :s^is^e: substitution failed [oracle@rh64 ~]$ echo this that this that [oracle@rh64 ~]$ ^is^e echo the that the that [oracle@rh64 ~]$
:g 做全域替換 [oracle@rh64 ~]$ echo abcd abef abcd abef [oracle@rh64 ~]$ !:gs/ab/cd echo cdcd cdef cdcd cdef [oracle@rh64 ~]$

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.