Logo 
Search:

Unix / Linux / Ubuntu Articles

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

Write s shell script, which will receive any number of filenames as arguments. The shell script should check whether every argument is a file or a dir

Posted By: Abelard Fischer     Category: Unix / Linux / Ubuntu     Views: 7316

Write s shell script, which will receive any number of filenames as arguments. The shell script should check whether every argument is a file or a directory. If it is directory it should be appropriately reported. If it is a filename then name of the file as well as the number of lines present in it should be reported.

Code for Write s shell script, which will receive any number of filenames as arguments. The shell script should check whether every argument is a file or a dir in Unix / Linux / Ubuntu

echo -n "Enter file or dir name : "
read name

if [ -d $name ]
then
    echo "Give name is directory"
elif [ -f $name ]
then 
    echo "File name is : $name"
    echo "No of line in file is : `wc -l $name | cut -d"" -f1`"
fi 
  
Share: 



Abelard Fischer
Abelard Fischer author of Write s shell script, which will receive any number of filenames as arguments. The shell script should check whether every argument is a file or a dir 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!