Adding comma between command line parameter Adding comma between command line parameter oracle oracle

Adding comma between command line parameter


"${*:2}" expands to the list of arguments starting at $2, separated by the first character of IFS:

saveIFS=$IFSIFS=","args="${*:2}"IFS=$saveIFSecho "$args"

Note that this properly preserves spaces within arguments, rather than converting them to commas.


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-`


This technique below, performing the echo in a subshell, allows you to set IFS and then let the changes disappear with the subshell

$ set -- "a b c" "d e f" "g h i"$ with_comma=$(IFS=,; echo "$*")$ echo "$with_comma"a b c,d e f,g h i