Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

-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.
 
PREVIOUS NEXT
Tagged: #shell #script
ADD COMMENT
Topic
Name
4+2 =