if you are interested to contribute your LAB PROGRAM Please send mail to jkumaron@gmail.com

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 ]
echo “ It is an ordinary file ”
elif [ -d $i ]
echo “ It is a directory file ”
echo “ It does not exist ”

OUTPUT DISPLAY FILE TYPE CS1252 Operating Systems lap
[redhat35@localhost Rhel5]$ sh type.sh
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

Related post