Shell script help
Morning/Afternoon All,
Once again I need to pick the brains of the unix guru's. I'm writing a shell script (OS is Mac OS X 10.4 / 10.5, typically using sh as the interpreter, but I guess I could use bash instead) and what I want to do is to remove leading and trailing spaces from a variable in the script (it's actually argument 1 that's passed to the script) but to retain any spaces that are within the actual variable. Here's an example of what the variable could contain: (space)(space)This(space)is(space)a(space)test(spa ce)(space)(space) The result after processing I would like is: This(space)is(space)a(space)test So, chop off leading and trailing, but keep the spaces within the actual string. How could I accomplish this? |
Hi Markus
echo “(space)(space)This(space)is(space)a(space)test(sp ace)(space)(space) to” | sed -e"s/ */ /g" |
Thanks, much appreciated and exactly what I needed.
|
In UNIX land, sed is your best friend :D :D
|
All times are GMT +1. The time now is 04:18 AM. |
© 2024 MH Sub I, LLC dba Internet Brands