I just started shell scripting, and I need to check if a file exists so I used command :
if [[-e "./doc/issues/$1.md" ]];
But the command seems to be invalid.
Does anybody knows why ?
You forgot to put a whitespace before -e, try :
if [[ -e "./doc/issues/$1.md" ]];
[[
is not mere syntax: it is (essentially) a command, and like every command, it needs a space to separate it from its arguments.
Commented
May 3, 2019 at 14:23
[[
and -e
-- and also -e
and the filename, and the filename and ]]
), and places where they're not allowed (like around the =
in an assignment), but very few places where they're optional. When copying an example, be sure to copy the spacing along with everything else.
Commented
May 3, 2019 at 15:00
[[-e
is one word without special meaning. I contrast, [[ -e
are 2 words. [[
opens a condition test mode and -e
is a condition that accepts the next word as param.