#!/bin/bash
COUNTER=$#
until [ $COUNTER -eq 0 ]; do
args[$COUNTER]=\$$COUNTER
let COUNTER-=1
done
echo ${args[@]}
When i run this, I get the following results
user@host:~/sandbox# ./script.sh first second third
$1 $2 $3
and i'm expecting it to echo out what $1, $2, and $3 are not a text value of "$1"
I'm trying to write a script in bash that will create an array that is the size of the number of arguments I give it.
I'm expecting
user@host:~/sandbox# ./script.sh alpha bravo charlie
alpha bravo charlie
or
user@host:~/sandbox# ./script.sh 23425 jasson orange green verb noun coffee
23425 jasson orange green verb noun coffee
So, the goal is to make
args[0]=$1
args[1]=$2
args[2]=$3
args[3]=$4
The way that I have it, the $1,$2,$3
aren't being interpolated but just being read as a text string.