Dear Grzegorz,
Thanks for your helpful reply.
Grzegorz Adam Hankiewicz wrote:
On 2006-12-27, Richard Neill <[EMAIL PROTECTED]> wrote:
1)substr support for a negative length argument.
For example,
stringZ=abcdef
echo ${stringZ:2:-1} #prints cde
i.e. ${string:x:y}
returns the string, from start position x for y characters.
but, if x is negative, start from the right hand side
and if y is negative, print up to the end, -y.
This would work the same way as PHP, and be extremely useful for, say,
removing an extension from a filename.
If extension removal is all you need, you can already do it.
$ for f in *; do echo $f; done
Makefile.am
Makefile.in
ucl
$ for f in *; do echo ${f%.*}; done
Makefile
Makefile
ucl
I did know about this, but it seems slightly like a sledgehammer on a
nut, using a regexp instead of a substring. Also, this way doesn't allow
you to trim both the start and the end. Lastly, I just think it would be
a really useful (and easy-to-implement, I think) feature, which is
consistent with the use of PHP and perl. At the moment, the first
parameter may be any integer (postive or negative), but the second
parameter can only be positive.
Best wishes,
Richard
_______________________________________________
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash