Answers for "-f in shell script"

0

-f in shell script

#-f in shell script is used to check if a file exists or not

filename=/home/root/sample.txt
if [ -f $filename ]
 then
     echo "File exists"
 else
     echo "File doesn't exists"
 fi
 
 Note: You can directly give the file name inside brackets.
Posted by: Guest on March-31-2022

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language