View the number of files in each subfolder of a specified folder in Linux

View the number of files in each subfolder of a specified folder in Linux

count script

#!/bin/sh
numOfArgs=$#
if [ $numOfArgs -ne 1 ]; then
  echo -e "Usage: \nbash $0 dirForCount"
  exit -1
fi
# args
ROOTDIR=$1
# core part
find $ROOTDIR -maxdepth 1 -type d | sort | while read dir; do
count=$(find "$dir" -type f | wc -l)
echo "$dir: $count"
done

implement

$ bash count.sh benchmark
benchmark: 2317
benchmark/0: 20
benchmark/1: 891
benchmark/2: 65
benchmark/3: 13
benchmark/4: 1328

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • Linux shell command counts the value of a column after deduplication
  • Tips for viewing History records and adding timestamps in Linux
  • Several ways to run Python programs in the Linux background
  • Creating and executing Linux shell scripts
  • Python uses paramiko to operate Linux
  • Android's implementation method of executing shell scripts in the Linux terminal to directly print the log of the currently running app
  • How to remotely batch execute Linux command programs using pyqt
  • Use of Zabbix Api in Linux shell environment
  • How to recover accidentally deleted messages files in Linux
  • Shell command to realize the method of merging multiple files in the current directory into one file

<<:  mysql join query (left join, right join, inner join)

>>:  How to import js configuration file on Vue server

Recommend

Implementation of nginx flow control and access control

nginx traffic control Rate-limiting is a very use...

A brief discussion on the solution to excessive data in ElementUI el-select

Table of contents 1. Scenario Description 2. Solu...

Vuex implements a simple shopping cart

This article example shares the specific code of ...

sql script function to write postgresql database to implement parsing

This article mainly introduces the sql script fun...

Not a Chinese specialty: Web development under cultural differences

Web design and development is hard work, so don&#...

MySQL installation tutorial under Centos7

MySQL installation tutorial, for your reference, ...

Linux concurrent execution is simple, just do it this way

Concurrency Functions time for i in `grep server ...

MySql knowledge points: transaction, index, lock principle and usage analysis

This article uses examples to explain the princip...

Analysis of idea compiler vue indentation error problem scenario

Project scenario: When running the Vue project, t...

How to check the version of Kali Linux system

1. Check the kali linux system version Command: c...

W3C Tutorial (12): W3C Soap Activity

Web Services are concerned with application-to-ap...

A brief discussion on whether CSS will block page rendering

Maybe everyone knows that js execution will block...