file test operator
Linux , Devops , c , c++ , python
#! /bin/bash
echo -e "Enter the name of the file: \c"
# -e flag for /c so the cursor stays on the same line
read file_name
if [ -d $file_name ]
# {-f... for regular file }, {-d ... for directory }
# {-c ... for character special file } , { -b ... for block special file }
then
echo "$file_name File Found"
else
echo "$file_name File Not found"
fi
echo -e "Enter the name of the file: \c"
read file_name
if [ -x $file_name ]
then
echo "$file_name File Not Empty"
else
echo "$file_name File Empty"
fi