The following is the script I am running
#$1 - Argument
declare IPATH="sample/"
declare F=$IPATH$1
echo $F
ls $F
The input is ./script.sh "Fil*"
The echo output is -
sample/Fil*
when I run the command ls sample/Fil*
I get the required output - A list of files whose name begins with FIL and are in the sample folder as this -
sample/File sample/File1 sample/File2
But the script throws the below exception. What am I doing wrong?
ls: sample/Fil*: No such file or directory ls: $IPATH: No such file or directory
ls: $IPATH: No such file or directory
part of the error doesn't make any sense -- as the script is written, thels
command should never see$IPATH
, that should've been replaced by its value long before it got nearls
. Try addingset -x
at the beginning to enable tracing, and see what that prints about how it's running.