Question:
Write a script whether the provided path type is file or dir
#!/usr/bin/bash
#this script is for command line arguments
path=$1
if [ -f $path ]
then
echo "the provided path type is file, you can read the content in any editor"
else
if [ -d $path]
then
echo "the provided path type is not a file ,it is a Dir"
fi
fi
Output :
the provided path type is file, you can read the content in any editor
Note;
-f checks for file type
-d checks for directory
No comments:
Post a Comment