The script is called isFile.sh and looks like this:
#!/bin/shecho $1 echo $2
if [ ! -f $1 ]; then echo "$1 (arg1) is not a file" fi
if [ ! -f $2 ]; then echo "$2 (arg2) is not a file" fi
First I created a file by doing touch file.exist
.
And I ran bash isFile.sh file.exist file.notexist
The output was:
file.exist
file.notexist
file.notexist (arg2) is not a file
Then I ran bash isFile.sh "" file.notexist
The output was:
(# empty line)
file.notexist
file.notexist (arg2) is not a file
Expected output is:
(# empty line)
file.notexist
(arg1) is not a file
file.notexist (arg2) is not a file
Can somebody explain why?
echo$1
? I would think it isecho $1
(better cut an paste). And welcome! – Volker Siegel Aug 07 '18 at 06:01echo $1
, I edited my question, thanks. – SoloKyo Aug 07 '18 at 06:04