4. bashのヒストリ展開を活用する 4
!-!-nn
●
n 回前に実行したコマンドの再実行
– コンパイル→実行の繰り返しなどに便利
$ platex foo.tex
This is pTeX, Version 3.141592-p3.1.9 (euc) (Web2C 7.5.4)
:
$ xdvi foo.dvi
$ !-n
platex foo.text
:
$!-n
xdvi foo.dvi
5. bashのヒストリ展開を活用する 5
^^foofoo^^barbar
● 直前に実行したコマンドの foo を bar に変更して実行
– 最初に検出された foo を bar に変更する
$ pletex foo.tex
-bash: pletex: command not found:
$ ^e^a
platex foo.tex
This is pTeX, Version 3.141592-p3.1.9 (euc) (Web2C 7.5.4)
:
6. bashのヒストリ展開を活用する 6
!:[g]s/!:[g]s/foo/barfoo/bar
● 直前に実行したコマンドの foo を bar に変更して実行
– 区切り文字の "/" を任意の文字に変更可能
– g を指定した場合全ての foo が bar に変更される
$ dir /x
dir: cannot access /x: No such file or directory
$ !:s+/+-
dir -x
$ dir /x /a
dir: cannot access /x: No such file or directory
dir: cannot access /a: No such file or directory
$ !:gs+/+-
dir -x -a