0
0

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 1 year has passed since last update.

【Linux】コマンドでファイル数を出力する方法

Posted at

lsコマンド

lsコマンドを使用してファイル数を出力するには以下のように実行します。

ls -fp パス | grep -v / | wc -l
  • ls -fp パス
    ディレクトリ内のファイル一覧を表示。
    ファイルを並べ替えずドットファイルも含めて表示。
    ディレクトリの場合/を出力。
  • grep -v /
    /を含まないもののみ出力。
  • wc -l
    出力結果の行数をカウント。

findコマンド

findコマンドを使用してファイル数を出力するには以下のように実行します。

find パス -type f | wc -l
  • find パス -type f
    指定したパス以下の全ファイルのパスを出力。
  • wc -l
    出力結果の行数をカウント。
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?