Issue
I tried using tree command but I didn't know how .(I wanted to use tree because I don't want the files to show up , just the number) Let's say c is the code for permission For example I want to know how many files are there with the permission 751
Solution
Use find
with the -perm
flag, which only matches files with the specified permission bits.
For example, if you have the octal in $c
, then run
find . -perm $c
The usual find
options apply—if you only want to find files at the current level without recursing into directories, run
find . -maxdepth 1 -perm $c
To find the number of matching files, make find
print a dot for every file and use wc
to count the number of dots. (wc -l
will not work with more exotic filenames with newlines as @BenjaminW. has pointed out in the comments. Source of idea of using wc -c
is this answer.)
find . -maxdepth 1 -perm $c -printf '.' | wc -c
This will show the number of files without showing the files themselves.
Answered By - CH. Answer Checked By - Mary Flores (WPSolving Volunteer)