7
5

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.

直前の出力を使ってコマンド実行する `!!`

Last updated at Posted at 2013-07-15

find -name 〜 -exec ""{} \;みたいなコマンドがあるかと思いますが、ちょっと覚えられないですよね。
また、条件式を末尾ではなく途中に書くというのが書きづらい。
以下の方法は使いやすいと思いますのでどうぞ。

  • ディレクトリ以下のphpファイルを全部vimで開きたい場合
$ find . | grep -v vendor | grep -v cache | grep php$
$ vim `!!`
  • ディレクトリ以下にtest1〜test20までのフォルダを作ったが、やっぱり削除したい
$ mkdir $(printf test%d\  `seq 1 20`)
$ find . -type d | grep test
$ rmdir `!!`
  • 指定したディレクトリの容量を表示したい
$ ls test*
$ du -sh `!!`
  • その他使い方例
$ apt-cache search mplayer | cut -d ' ' -f 1
$ printf "[package: %s]\n" `!!`
7
5
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
7
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?