Linux
Wed Nov 29 2023 07:44:49 GMT+0000 (Coordinated Universal Time)
Saved by
@viinod07
Write a shell script that takes a command -line argument and reports on whether it is
directory, a file, or something else.
Script:
echo " Enter File Name"
read str
if [ -f $str ]
then
echo "File exists and it is an ordinary file"
elif [ -d $str ]
then
echo "directory file"
else
echo "not exists"
fi
if [ -c $str ]
then
echo "character device files"
fi
Output:
Enter File Name
Samplefile
File exists and it is an ordinary file
content_copyCOPY
Comments