1
2

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 3 years have passed since last update.

ターミナルで文字列を探すコマンド

Last updated at Posted at 2019-12-26

文字列がどこにあるか探したい

いちいちファイルを開いて検索かけて探すのは面倒 ...

そんな時は

terminal
$ find ./ -type f -print | xargs grep 探したい文字列

これを使えば一発
でも、こんな長いの叩くのはナンセンスなので
aliasでお好みのコマンドに設定しよう => aliasについて

以下、作成したコマンドを使用して実行します。

今回使うファイル

ファイル構成
hoge
  ├── file      (含まれる文字列)
  │   ├── a.txt (Good)
  │   ├── b.txt (Better)
  │   └── c.txt (Best)
  └── text
      ├── d.txt (I)
      ├── e.txt (My)
      └── f.txt (Me)

実際に使ってみる

terminal
$ fw Goo
.//file/a.txt:Good

$ fw B
.//file/c.txt:Best
.//file/b.txt:Better

$ fw M
.//text/e.txt:My
.//text/f.txt:Me

こんな感じ

終わり

(VSCodeだったら command + shift + f で検索できるんですけどね)
aliasについての記事

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?