I want to write a script which will check the arguments and if there is a single space(if 2 more more space in a row , then do not touch), replace it with _ and then gather the argument
so, program will be ran
./programname hi hello hi usa now hello hello
so, inside of program, after going through my little script, it should come out as
$1 = hi
$2 = hello_hi
$3 = usa
$4 = now
$5 = hello_hello
It's rather diffuclt for me since I am not sure even if I got rid of space and replace it with _, not sure how to assign back to correct positional parameters..
thanks guys.. but I am writing this script so that end user can be as lazy as possible(since they are copying from somewhere and pasting it as arguments).
I thought maybe I can do it as put the whole argument as array.. and then after doing the replacing( " " to _ ) and then assign it back to $1,$2 .... ?
is this not possible in shell script?
so, my logic would be,
./scriptname whatever whatever1 whate ever2 whate ver 2006
so, script would see it as @arrayname = $* # or possibly
value = $1,$2,$3,$4,$5,$6 <--i would insert extra just in case
and then possibly break it out using sed and awk.. but not sure how to assign it back...
newvalue =