LoginSignup
1
0

More than 3 years have passed since last update.

任意のディレクトリ群の中のファイル数を数え上げるシェルスクリプト

Posted at

普段シェルスクリプトを書かないのでメモっておく
"d"で始まって"1"か"2"で終わる全てのディレクトリの中にある全てのファイルを数え上げる

n_files=0
for dir_name in `ls | grep ^d | grep [12]$`
do
  n_files=$((n_files += `ls -1 $dir_name | wc -l`))
done
echo $n_files
1
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
1
0