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
It is a directory file
[redhat35@localhost Rhel5]$ sh
It is an ordinary file
[redhat35@localhost Rhel5]$ sh
It does not exist

No comments:
Write comments