Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Stripping spaces from a shell variable, portably
- X-seq: zsh-workers 19160
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh <zsh-workers@xxxxxxxxxx>
- Subject: Re: Stripping spaces from a shell variable, portably
- Date: Wed, 1 Oct 2003 15:14:52 +0000
- In-reply-to: <20031001092757.GA31207@DervishD>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20031001092757.GA31207@DervishD>
On Oct 1, 11:27am, DervishD wrote:
}
} I need to strip leading and trailing spaces from the contents of
} a shell variable, and I need to do it [...] using SuSv3
} constructs, not Zsh extensions.
What about:
tmp="${variable##*[^ ]}"
variable="${variable%${tmp}}"
tmp="${variable%%[^ ]*}"
variable="${variable#${tmp}}"
Messages sorted by:
Reverse Date,
Date,
Thread,
Author