Basic Shell scripting with control structures. Counting the number of directories and files and whether they are readable writeable and executable -
write shell script calculates following information contents of given directory. directory specified single command line argument script. not need account contents of nested subdirectories -- direct contents of specified directory.
the total number of directories in given directory (note these subdirectories). total number of files in given directory. number of items (files/directories) in current directory readable. number of items (files/directories) in current directory writable. number of items (files/directories) in current directory executable.
i tried :
if [ -d $file ] counter=expr $counter + 1 echo "number of directories :" $counter fi
i won't write script you, 1 way obtain answer use ls -l association grep -c, using grep parse out appropriate filesystem flags (the drwxrwxrwx column) ls -l give you. key knowing how parse column grep.
it may not efficient (as we're doing ls multiple times, give you're looking for.
Comments
Post a Comment