Bash: How to Check if a File or Directory Exists
Aug 30, 2019 · How to Check if a File Exists. To test for the file /tmp/test.log, enter the following from the command line: test –f /tmp/test.txt. The first line executes the test to see if the file exists. The second command, echo, displays the results 0 meaning that the file exists, 1 means no file was found. echo $? In our example, the result was 1.
DA: 28 PA: 28 MOZ Rank: 70 Up or Down: Up