5
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 2016-02-11

やりたいこと

カレントディレクトリにあるファイルの行数を一覧表示したい。

従来の手法:

>wc -l*

↑でもできるが、以下のようにディレクトリとファイルが混ざって表示されるのでなんとかしたい。

表示例(ちょっと見にくい):

>wc -l *
      5 aaaa_file
wc: dir1: ディレクトリです
      0 dir1
wc: dir2: ディレクトリです
      0 dir2
     10 file1
     27 file2
      9 file3
     51 合計

実行コマンド:

wc -l * | lv | cat

一度lvを通してそれをcatで表示するとディレクトリとファイルが混ざって表示されなくなる。

エイリアスの設定例:

alias wl='wc -l * | lv | cat'

としてあげると、wlコマンドを作成できる。

実行例:

>wl
wc: dir1: ディレクトリです
wc: dir2: ディレクトリです
      5 aaaa_file
      0 dir1
      0 dir2
     10 file1
     27 file2
      9 file3
5
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
5
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?