Bash 下的快捷操作

之前看到一篇讲Bash命令操作的文章,我对一些常用的操作做了下简单记录,这里主要是对上一条命令做更改。


删除不需要的字符

    grep fooo /var/log/auth.log
    ^o
    grep foo /var/log/auth.log
    # ^str 只对第一次出现的str有效

用”^old^new” 替换字符

    cat myflie
    ^li^il
    cat myfile

在历史命令中查找命令

history | grep string

执行前一条命令

    !!          # execute the previous command
    sudo !!     # 
    !str        # execute the history command about the head is "str"
                !cma
                cmatrix
    !?str       # execute the history command about include "str"
                !his
                history 10 | grep javac
    !-n         # execute the history command about sorb by inverted sequce
                !-2
                cd -
    !#          # $yinYong the current line
                cp filename filename.old
                cp filename !#:1.old
    !$			# $yinyong the previous command and the last parameter
                mkdir videos
                cd !$      # alias [Alt + .]
    !^          # $yinyong the previous command and teh first parameter
                ls /usr/share/doc /usr/share/man
                cd !^       
    !:n         # $yinyong the previous line and the n_th parameter
                touch foo.txt bar.txt baz.txt
                vim !:2     # vim bar.txt
    !:n-m       # $ get the parameter from n to m
                tourch foo.txt bar.txt baz.txt
                vim !:1-2
    !:n*        # $ get the parameter from n to the end
                cat /etc/resolv.conf /etc/hosts /etc/hostname
                vim !:2*    # vim /etc/hosts /tec/hostname
    !*          # get the all parameter from the previous line
                ls code src
                cp -r !*

important principle

Type less, accomplish more  
don't repeat yourself   
Care about your tools
Command is everything           
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值