0

I have a bash script that takes in arguments from the command line:

path2self=$(dirname "$(readlink -f "$0")")

path2Intersection=$1
normal=$2
matched=$(echo "$3" | awk '{print tolower($0)}')
csv=$4
f1=$5
f2=$6
f3=$7
f4=$8
r1=$9
path2database=$10
b1=$11
b2=$(echo "$12" | awk '{print tolower($0)}')
b3=$13

echo $path2database
echo $b1

However, if I run it with this: sh /path/to/script.sh /path/to/Intersection /path/to/normal true /path/to/csv.csv 4 10 0.05 0.01 mut /path/to/databases /path/to/b1 true /path/to/b3 I get this output:

/path/to/Intersection0
/path/to/Intersection1

I don't know why the argument is passing what I send to it through the command line isn't the same. Does anyone know what is going on?

Victor M
  • 603
  • 4
  • 22

1 Answers1

2

$10 will end up as the concatenation of the value of $1 and '0' as you can perfectly observe in your result. Same goes for $11 and all others that have more than one digit.

Simply add curly braces around your identifiers to expand the variable correctly => ${10}

Zeitounator
  • 38,476
  • 7
  • 53
  • 66