Check Linux file type and DISPLAY FILE TYPE using bash scripting in linux Unix shell scripting

These following shell scripting is used to check the give data is file or directory. File indicate by the ‘f’ and directory indicate by the ‘d’ by using these symbol it will display the file type. See the basic Linux file permission. shell scripting using if and else if condition it will check the file type. If the file is not directory or file then it will display it does not exit in these bash script – shell script CS1252 Operating Systems lap
Source code bash shell Programming Algorithm
read i
if [ -f $i ]
then
echo “ It is an ordinary file ”
elif [ -d $i ]
then
echo “ It is a directory file ”
else
echo “ It does not exist ”
fi

OUTPUT DISPLAY FILE TYPE CS1252 Operating Systems lap
[redhat35@localhost Rhel5]$ sh type.sh
a
It is a directory file
[redhat35@localhost Rhel5]$ sh big.sh
It is an ordinary file
[redhat35@localhost Rhel5]$ sh i.sh
It does not exist

Post a Comment

0 Comments