Adding comma between command line parameter
bash, oracle, scripting, shell, unix
Solution
All parameters is `$@`. You can use `sed` to replace spaces with commas and then(or from the begining, `cut` the first field)
echo $@ | sed s/" "/,/g | cut -d "," -f2-
a step forward, you can assign it to a variable:
comma_separated_params=`echo $@ | sed s/" "/,/g | cut -d "," -f2-`
Problem
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