help-bash
[Top][All Lists]
Advanced

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

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


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

I noticed it's apparently legit to say the following:

string='hello this  is   a    test     '
echo "'${string}'" original

echo "'${string%[[:space:]]}'"
echo "'${string%[[:space:]]*}'"
echo "'${string%%[[:space:]]*}'"

Produces:
address@hidden ycc# ./tst
'hello this  is   a    test     ' original
'hello this  is   a    test    '
'hello this  is   a    test    '
'hello'

I tried it with a tab character at the end of the string and that also works.

Is there any syntactically correct way to provide an * or + multiplier on to this to get rid of all the white space at the end of a line?

--
Bill Gradwohl


reply via email to

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