class: center, middle, inverse # 高效使用 ``` __ _ / / (_)__ __ ____ __ / /__/ / _ \/ // /\ \ / /____/_/_//_/\_,_//_\_\ ``` ## 命令行 ``` xiaodong25 2015.4 ``` --- class: center, middle, inverse # ^old^new ![replace](img/demo.gif) --- class: center, middle, inverse # ^old ![delete](img/demo1.gif) --- class: center, middle, inverse # !:gs/old/new ![global](img/demo2.gif) `` --- class: center, middle, inverse # 历史展开模式 ![History](img/hist.png) --- class: center, middle, inverse # !! 上一条命令 ![bangbang](img/demo3.gif) ``` % !! (1) % sudo !! (2) ``` --- class: center, middle, inverse # !foo foo 开头的命令 ![begin](img/demo4.gif) --- class: center, middle, inverse # !?foo 含 foo 的命令 ![include](img/demo5.gif) --- class: center, middle, inverse # !n 第 n 个命令 ![number](img/demo6.gif) --- class: center, middle, inverse # !-n 倒数第 n 个命令 ![number](img/demo7.gif) ``` % !-1 == ? ``` --- class: center, middle, inverse # Word 选取图 ![history words](img/hist-word.png) --- class: center, middle, inverse # !$ 上条命令最后一位 ![number](img/demo8.gif) ``` !!:$ == !$ ``` --- class: center, middle, inverse # !^ 上条命令第一位 ![number](img/demo9.gif) --- class: center, middle, inverse # !:n 上条命令第 n 位 ![number](img/demo10.gif) --- class: center, middle, inverse # !:x-y 上条命令 x - y ![number](img/demo11.gif) --- class: center, middle, inverse # !:n* 上条 n 到最后 ![number](img/demo12.gif) --- class: center, middle, inverse # !* 上条所有参数 ![number](img/demo13.gif) --- class: center, middle, inverse # 注意 ``` % !an:$ % !10:2-4 ``` --- class: center, middle, inverse # :h 选取路径开头 ![number](img/demo14.gif) ``` !!:$:h == !$:h ``` --- class: center, middle, inverse # :t 选取路径结尾 ![number](img/demo15.gif) --- class: center, middle, inverse # :r 选取文件名 ![number](img/demo16.gif) --- class: center, middle, inverse # :e 选取扩展名 ``` % echo abc.jpg % echo !$:e .jpg ``` --- class: center, middle, inverse # :p 打印命令行 ![number](img/demo17.gif) --- class: center, middle, inverse # :s 做替换 ``` % echo this that % !:s/is/e echo the that ``` 惯用法: ^is^e --- class: center, middle, inverse # :g 做全局替换 ``` % echo abcd abef % !:gs/ab/cd echo cdcd cdef cdcd cdef ``` --- class: center, middle, inverse # 深入阅读 ``` - bash: man history - Bash Reference Manual: https://www.gnu.org/software/bash/manual/html_node/index.html - Book: Unix Power Tools ``` --- class: center, middle, inverse # Q & A --- class: center, middle, inverse Made in [Remark](http://remarkjs.com)