I have a bash script which is supposed to print the arguments in two lines. The first line should be the first argument and the second line should be the rest of the arguments
#!/bin/bash
FIRST_ARG="$1"
shift
REST_ARGS="$@"
echo $FIRST_ARG
echo $REST_ARGS
This works fine for normal arguments such as
root@us:~# /bin/bash parse.sh testName test1 test2 test3
testName
test1 test2 test3
root@us:~#
However, what I want is to send a key value pair as the arguments such as
testName "X-Api-Key: 1be0ad48" "Name: someTest" "Interval: * * * * *"
I am expecting this to produce a result as follows
testName
"X-Api-Key: 1be0ad48" "Name: someTest" "Interval: * * * * *"
Including the quotes. However, I am getting the following as result
root@us:~# /bin/bash parse.sh testName "X-Api-Key: 1be0ad48" "Name: someTest" "Interval: * * * * *"
testName
X-Api-Key: 1be0ad48 Name: someTest Interval: parse.sh parse.sh parse.sh parse.sh parse.sh
root@us:~#
Two things happening extra here that I don't want. 1) It removes the quotes ", 2) It replaces * with the file name.
I tried escaping those with " but it didn't work. Is there a way to solve this? Where am I doing wrong in this?