Headlines
Loading...
UNIX program to check whether every argument supplied is a file or a directory

UNIX program to check whether every argument supplied is a file or a directory

Write a shell script, which will receive any number of filenames as arguments. The shell script should check whether every argument supplied is a file or a directory. If it is a directory it should be appropriately reported. If it is a filename then name of the file as well as number of lines present in it should be reported.
while [ $# -gt 0 ]
do
        if [ -d $1 ]
        then
                echo "$1 is a directory..."
        else
                echo "$1 is a file..."
                echo "$1 has `wc -l $1` lines"
        fi

        shift
done
*** PLEASE checkout the Best deals from for top sites like Amazon, Flipkart etc ***