linux file statistics operation

Traverse folder statistics statement:
for dir in `find /alidata1/trip/img/ -type d ` ;do echo -n "$dir "  ;find $dir -name "*.jpg"  -type f | wc -l ;echo "" ;done;

Statement description:
  • The for dir in loop processes the list of folders queried by `find /opt -type d`,
  • do echo -n "$dir " output folder name
  • find $dir -name "*.jpg" -type f | wc -l ; count the number of files in a folder
  • done ends the loop

Parameter Description:
  • -type file type matches d folders, f files
  • -name The file name matches *.jpg to match the file with the suffix jpg

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326425311&siteId=291194637