[英]How to find and count directory and files found in 'find'
How to find and count directory and files found in find util in Bash Linux, and put in env.如何在 Bash Linux 中的 find util 中找到并计算目录和文件,并放入 env。 variable, or print out, or both, each eg
变量,或打印出来,或两者兼而有之,每个例如
NUM_FILE=
NUM_DIR=
of: (just illustration)的:(只是说明)
find . -type d ...... -o type f .......... -print..... # ???
Assuming that your directory/filenames don't contain newlines, piping the output of the find
command into wc -l
gives you the total number.假设您的目录/文件名不包含换行符,将
find
命令的 output 管道传输到wc -l
会给您总数。
Using the usual command substitution, var=$(....)
, puts the figure into a variable.使用通常的命令替换
var=$(....)
,将图形放入变量中。
When you want to count a file with newlines only once, print a dot for every file:当您只想用换行符计算一个文件时,为每个文件打印一个点:
NUM_FILE=$(find . -type f -printf "." | wc -c)
NUM_DIR=$(find . -type d -printf "." | wc -c)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.