Alfred M. Szmidt wrote:
> Evan Hunt wrote:
> > Regarding the original query, why not just use awk?
Or just use basename with a little xargs added. This seems very
readable and obvious to me.
echo /home/me/foo | xargs -l basename
foo
And then zero terminated strings are already supported.
printf "/home/me/foo\0" | xargs -0 -l basename
> You have touched a nerve... :-) From the top of my head:
>
> cat -- sed ':'
> tac -- sed '1!G;h;$!d'
> grep -- sed 'PATTERN/!d'
> head -- sed '10q'
> tail -- sed -e ':a' -e '$q;N;11,$D;ba'
> dirname -- sed 's;[^/]*$;;'
> basename -- sed 's;.*/;;'
> cp OLD NEW -- sed 'w NEW' OLD
>
> One can always just use something else, but most often the something
> else is painful.
When trying to construct a filter are any of those alternatives really
that painful? The basename one in particular seems quite intuitive to
me.
Bob