Simply, checking in command-line, using the ls command
dev@ubuntu:/tmp$ ls -ltr myfile
ls: cannot access 'myfile': No such file or directory
Check using the test command
test -f myfile
This approach is more useful when you want to check in a script (bash or shell)
What is the result?dev@ubuntu:/tmp$ test -f myfile
dev@ubuntu:/tmp$
dev@ubuntu:/tmp$ echo $?
1
This file does not exist so will cause an exit status of 1
Now, let us create a file and test again
dev@ubuntu:/tmp$ touch myfile
dev@ubuntu:/tmp$ ls -l myfile
-rw-rw-r-- 1 dev dev 0 Aug 25 20:38 myfile
dev@ubuntu:/tmp$
dev@ubuntu:/tmp$ test -f myfile
dev@ubuntu:/tmp$
dev@ubuntu:/tmp$ echo $?
0
dev@ubuntu:/tmp$
Alternate method: Bash script check if file exists on remote server