Hi All, In the past, in bash, I have used the -e and -f options for checking if a file exists, adding ! to create not exists. In the LA course the -a option is used, which works until I use the !, then it fails. The -e and -f options work fine with or without the !.
The below code works in Terry's video, so it makes me think there is something different about my Linux envirnment. Any ideas?
[root@CentOS bin]# cat testfile.sh
# test for existence of indicated file name
echo "Testing for the existence of and file called $FILENAME"
if [ ! -a $FILENAME ]
echo "The file $FILENAME does NOT exist."
[root@CentOS bin]# ll
-rwxr-xr-x. 1 root root 251 Oct 3 13:43 simpleif.sh
-rwxr-xr-x. 1 root root 213 Oct 3 15:49 testfile.sh
[root@CentOS bin]# testfile.sh simpleif.sh
Testing for the existence of and file called simpleif.sh
The file simpleif.sh does NOT exist.
[root@CentOS bin]# testfile.sh askaslkas
Testing for the existence of and file called askaslkas
The file askaslkas does NOT exist.