知识屋:更实用的电脑技术知识网站
所在位置:首页 > 操作系统 > linux

linux命令技巧

发布时间:2015-09-13 22:06:12作者:知识屋

[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 ~]$
(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)
收藏
  • 人气文章
  • 最新文章
  • 下载排行榜
  • 热门排行榜