3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

shell > 前に打ったコマンドを再度実行 > !cat / !ls

Last updated at Posted at 2015-04-18
動作環境
CentOS 6.5
bash

!catとすると最後に実行したcatコマンドを、!lsとすると最後に実行したlsコマンドを再実行できるようだ。
SOのやり取りの中で記載されていた。

$ cat sample.dat
と実行したあと
$ !cat
とすると cat sample.dat と同じ動作になるようだ

!lsなど他のコマンドでも同じようだ。

これを利用すると

$ ifort func_nanigashi.f func_koremoHoshii.f func_kotiramoHitsuyoudarou.f main.f -lm -lpthread -lNankanoLibrary

を実行して、そのあとにshellで色々作業した後、再度コンパイルしたい時

$ !ifort

一発で済む。

(ctrl+rでifortの過去履歴を探すのとどちらが便利かは今のところわからない)


(2015/05/02追記) http://www.gnu.org/software/bash/manual/bash.html#Event-Designators > !string > Refer to the most recent command preceeding the current position in the history list starting with string

上記のリンク先の9.3.1に他の説明もある。
(Thanks to ~kbk).

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?