Shell script help
#1
Scooby Regular
Thread Starter
Join Date: Mar 1999
Location: The Great White North
Posts: 25,080
Likes: 0
Received 0 Likes
on
0 Posts
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?
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?
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
28 December 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
18 November 2015 07:03 AM