Logo 
Search:

Unix / Linux / Ubuntu Articles

Submit Article
Home » Articles » Unix / Linux / Ubuntu » Homework HelpRSS Feeds

Write a script to count and report the number of entries in each subdirectory mentioned in the path, which is supplied as a command-line argument

Posted By: Adriane Miller     Category: Unix / Linux / Ubuntu     Views: 4117

Write a script to count and report the number of entries present in each subdirectory mentioned in the path, which is supplied as a command-line argument.

Code for Write a script to count and report the number of entries in each subdirectory mentioned in the path, which is supplied as a command-line argument in Unix / Linux / Ubuntu

if [ $# -eq 0 ]
then
    echo "Enter path : "
    read path
else
    path=$1
fi

for dir in `ls -R $path`
doif [ -e $dir ]
    then
        vcount=`expr $vcount+1`
        echo $dir
    fi
done
    echo "There is $vcount file"
  
Share: 



Adriane Miller
Adriane Miller author of Write a script to count and report the number of entries in each subdirectory mentioned in the path, which is supplied as a command-line argument is from Frankfurt, Germany.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!