linux命令技巧,linux命令

來源:互聯網
上載者:User

linux命令技巧,linux命令
[oracle@rh64 ~]$ cat lgrw.txtcat: lgrw.txt: No such file or directory[oracle@rh64 ~]$ ^rw^wrcat lgwr.txt18:03:19.703928 times({tms_utime=27, tms_stime=18, tms_cutime=0, tms_cstime=0}) = 43367818618: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}, ...}) = 018:03:21.364760 getrusage(RUSAGE_SELF, {ru_utime={0, 278957}, ru_stime={0, 184971}, ...}) = 0
[oracle@rh64 ~]$ history --10-bash: history: --: invalid optionhistory: 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 /data1mount /dev/mapper/vg0-lv1 /data1[oracle@rh64 ~]$ !:gs/1/2echo mount /dev/mapper/vg0-lv2 /data2mount /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 ~]$ !catcat /etc/passwdroot:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologindaemon:x:2:2:daemon:/sbin:/sbin/nologinadm:x:3:4:adm:/var/adm:/sbin/nologin
!?cat 含cat的命令[oracle@rh64 ~]$ !?catcat /etc/passwdroot:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologindaemon: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.txta.txt[oracle@rh64 ~]$ !$:ta.txt-bash: a.txt: command not found[oracle@rh64 ~]$ echo !$:recho aa:e 選取副檔名[oracle@rh64 ~]$ echo abc.jpgabc.jpg[oracle@rh64 ~]$ echo !$:eecho .jpg.jpg
:p 列印命令列[oracle@rh64 ~]$ !e:pecho .jpg[oracle@rh64 ~]
:s 做替換% echo this that% !:s/is/eecho the that慣用法: ^is^e[oracle@rh64 ~]$ echo this thatthis that[oracle@rh64 ~]$ !:s/is/eecho the thatthe that[oracle@rh64 ~]$ ^is^e-bash: :s^is^e: substitution failed[oracle@rh64 ~]$ echo this thatthis that[oracle@rh64 ~]$ ^is^eecho the thatthe that[oracle@rh64 ~]$ 
:g 做全域替換[oracle@rh64 ~]$ echo abcd abefabcd abef[oracle@rh64 ~]$ !:gs/ab/cdecho cdcd cdefcdcd cdef[oracle@rh64 ~]$ 
深入閱讀- bash: man history
- Bash Reference Manual:  https://www.gnu.org/software/bash/manual/html_node/index.html
- Book: Unix Power Tools

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

相關文章

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.