[email protected] ~]$ cat lgrw.txtcat:lgrw.txt:No such file or Directory[[email protected] ~]$ ^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, {{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
[Email protected] ~]$ history--10-bash:history:--: Invalid optionhistory:usage:history [-c] [-D offset] [n] or Histo RY-ANRW [filename] or history-ps arg [arg ...] [Email protected] ~]$ ^--history 1002 Ls-lte [[email protected] ~]$ echo mount/dev/mapper/vg0-lv1/data1mount/dev/ Mapper/vg0-lv1/data1[[email protected] ~]$!:gs/1/2echo MOUNT/DEV/MAPPER/VG0-LV2/DATA2MOUNT/DEV/MAPPER/VG0-LV2/ Data2[[email protected] ~]$
Reference command Line! [!| [?] String| [-]number]
: [N|x-y|^|$|*|n*|%]:[h|t|r|e|p|s|g]-------Select word--------modifier-----
!! ---the previous command!cat the command starting with cat [[email protected] ~]$!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 with cat commands [[email protected] ~]$!? 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 nth Command!-n the countdown nth command
!$ last command.
!^ the first command on the top of the line
!:n Upper command Nth bit
!:X-Y Upper command X-y
!:n* N to the last
!* all parameters on the bar
: H Select the beginning of the path
: T Select path end
: r Select File name [[email protected] ~]$ echo a.txta.txt[[email protected] ~]$!$:ta.txt-bash:a.txt:command not found[[email prote CTED] ~]$ echo!$:recho aa:e pick extension [[email protected] ~]$ echo abc.jpgabc.jpg[[email protected] ~]$ echo!$:eecho. jpg.jpg
:P Print command line [[email protected] ~]$!e:pecho. Jpg[[email protected] ~]
: s do replace% echo this that%!:s/is/eecho the same idiom: ^is^e[[email protected] ~]$ echo this thatthis that[[email protected] ~] $!:s/is/eecho The thatthe that[[email protected] ~]$ ^is^e-bash:: s^is^e:substitution failed[[email protected] ~]$ Echo This thatthis that[[email protected] ~]$ ^is^eecho the thatthe that[[email protected] ~]$
: g do global replacement [[email protected] ~]$ echo ABCD ABEFABCD abef[[email protected] ~]$!:gs/ab/cdecho CDCD CDEFCDCD cdef[[email Prot Ected] ~]$
Deep Reading-Bash:man history
-Bash Reference manual:https://www.gnu.org/software/bash/manual/html_node/index.html
-Book:unix Power Tools
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Linux Command Tips