In: Computer Science
Linux
Have your script request a word from the user, then checks if it is an ordinary file. If yes display the size of the file. If the name is a directory, then display the number of objects in that directory, then display the second line of a long listing of that directory.
#!/bin/bash
if [ $# -ne 1 ]
then
echo "Enter filename as an argument"
exit 1
elif [ -f $1 ]
then
echo "$1 is a ordinary file and size of $1 is `stat -c
%s $1` Bytes"
else [ -d $1 ]
ls -l $1
fi
if you have any doubt then please ask me without any hesitation in
the comment section below , if you like my answer then please
thumbs up for the answer , before giving thumbs down please discuss
the question it may possible that we may understand the question
different way and i can edit and change the answers if you argue,
thanks :)