I want to call a procedure through unix script, it will be generic script so parameters can very. Calling statement will be some something like
<scriptname> <procedure name> <param1> <param2> <param3> <param4>.. so on
What I need is from 2nd command line paramater to last paramter I want all values comma separeted something like this
<param1>,<param2>,<param3>,<param4>
I can do this using a loop, that is from 2nd command line parameter I will itereate each parameter and add comma in it. My question is can I do this with single command?
Note :- Space should be handled properly if present is command line parameter, after last parameter there should not be any comma
"${*:2}" expands to the list of arguments starting at $2, separated by the first character of IFS:
saveIFS=$IFS
IFS=","
args="${*:2}"
IFS=$saveIFS
echo "$args"
Note that this properly preserves spaces within arguments, rather than converting them to commas.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With