I'm trying to write a script that has to check if a file exists. In the console I write
if [[ -a /path/to/file.txt ]]; then echo "not mod"; else echo "mod"; fi
and I get
but when I write a script to do the same thing:
#!/bin/sh if [[ -a /path/to/file.txt ]]; then echo "not mod"; else echo "mod"; fi
and then execute the script, I get this:
./ex.sh: 2: [[: not found mod
I saved the script on the current directory and named it ex.sh, then I made sure it is executable. To call the script I do this:
Why am I getting this problem? I already tried many things:
if [ -a /home ...
if test -a /home ...
Both of them return
13: -a: unexpected operator