help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Getting rid of white space with % and %%


From: Bill Gradwohl
Subject: Re: [Help-bash] Getting rid of white space with % and %%
Date: Mon, 21 May 2012 15:38:00 -0600

On Mon, May 21, 2012 at 3:23 PM, Greg Wooledge <address@hidden> wrote:
It appears you are trying to trim all the trailing whitespace from a
string variable.  You can do that with extended globs:

shopt -s extglob
echo "'${string%%+([[:space:]])}'"

Or if you don't want to use extended globs, you can do it two steps:

remove=${string##*[![:space:]]}
echo "'${string%$remove}'"

Normal globs (like the ones you were attempting to use) do not have a
full closure operator, so you can't say "0 or more spaces".


Thank You Greg.
--
Bill Gradwohl


reply via email to

[Prev in Thread] Current Thread [Next in Thread]