![](https://seccdn.libravatar.org/avatar/b12cfb65ca4faebc3e3aac17838e8f8d.jpg?s=120&d=mm&r=g)
Theo, Dylan, On Saturday 12 August 2006 02:08, Theo v. Werkhoven wrote:
Fri, 11 Aug 2006, by rschulz@sonic.net:
Theo, Dylan,
On Friday 11 August 2006 17:34, Theo v. Werkhoven wrote:
...
Forgot to mention: if you only want the trailing spaces removed, use this form: ${file//% /}
I think you mixed up the arbitrary substitution syntax with the trailing stripping syntax. It should be:
"${file%% }"
You're right, but it wasn't immediately clear to me (late night, yada yada yada) if Dylan wanted all spaces removed or only the trailing ones, so I chose the arbitrary syntax. Tnx.
Actually, I'm not right. The problem is that the shortest (single # or %) vs. longest (double # or %) are only distinguished when there's a * involved, and since these are not real regular expressions, but rather shell glob patterns, it's not possible to use any of the variable substitution expansions to achieve this affect. I believe it actually is necessary to use sed, perl or awk. Sed's my tool of choice for these things, so here's how it would work: % title=" One, two, buckle my shoe " % strippedTitle="$(echo -n "$title" |sed -r -e 's/^ +//' -e 's/ +$//')" % echo "[[$strippedTitle]]" [[One, two, buckle my shoe]]
Theo
Sorry for the erroneous information. Randall Schulz