I am having an issue while passing multiple string parameter which have spaces. I know there are answers but my scenario is different and not much aware of shell scripts too.
My shell script is having values as (its very simple script nothing else is there)
java -jar $PATH_TO_JAVA_MAIN $1 $2 $3 $4 $5
now $1 is only mandatory and others are optional. inputs to shell script is like Input from command line:
name:john address1:451 7th Street S.W address2:6430 Stream Side Court
now in java main method i get these in separate array index like
arg[1]=address1:451
arg[2]=7th
arg[3]=Street
arg[4]=address2:6430
arg[5]=Stream
arg[6]=Side
arg[7]=Court
but i want that address to as one string against address1 and address2.
i tried both way as inputs
name:john address1:"451 7th Street S.W" address2:"6430 Stream Side Court" result in String arg[] in my java class :
LOGGER.info("Input values args: "+Arrays.toString(args));
Input values args:[name:john, address1:451, 7th, Street, address2:6430, Stream, Side, Court]
Expected output :[name:john, address1:"451 7th Street", address2:"6430 Stream Side Court"] so that i can split with : and get the respective key values provided.