-f dans le script shell

#-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.
rachelgreen