LoginSignup
52
38

More than 5 years have passed since last update.

テキストファイルの内容をファイル名付きで表示する

Posted at

小さなテキストファイルがたくさんあって、一度にまとめて眺めたいときに grep はいかがでしょう。
cat だと内容しか表示されませんが grep "" だとファイル名付きで表示されます。
行番号も表示したいときは -n を指定します。

grep "" FILE1 FILE2 FILE3...
grep -n "" FILE1 FILE2 FILE3...

-H を指定すれば引数のファイルが一つでもファイル名を表示させることができます。
-H をサポートしていない grep では代わりに /dev/null を指定します。

grep -H "" FILE1
grep "" /dev/null FILE1
52
38
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
52
38