Reputation: 245
Q2. Write a script that takes a directory name as command line argument and display the attributes of various files in it e.g.
working in linux in shell script
what i have done is
find DIR_NAME -type f -print | wc -l
To count all files (including subdirs):
find /home/vivek -type f -print| wc -l
To count all dirs including subdirs:
find . -type d -print | wc -l
To only count files in given dir only (no subdir):
find /dest -maxdepth 1 -type f -print| wc -l
To only count dirs in given dir only (no subdir):
find /path/to/foo -maxdepth 1 -type d -print| wc -l
Upvotes: 2
Views: 9955
Reputation: 74118
All your questions can be solved by looking into man find
-type f
-type d
-perm /u+w,g+w
or some variation-perm /u+r,g+r
-perm /u+x,g+x
-size 0
-name '.*'
Upvotes: 2