Skip to main content

Command Palette

Search for a command to run...

file test operator

Published
•1 min read•View as Markdown
O

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