I'm getting sorrier by the moment I helped flame this idiotic thread, but:
On Mon, Jun 03, 2002, Moshe Zadka wrote about "Re: How many Linux-IL members are needed to replace a light bulb? (was: Re: small and extremely annoying question)": > I'm a sed/awk man myself. > > echo /bin/hello | sed 's#[^/]*$##' But this solution uses two processes if echo is not a shell builtin! Better do it with one (and add a / where you forgot): $ FILE=/bin/hello $ sed 's#/[^/]*$##' << END $FILE END /bin By the way, obviously all these solutions (sed, rev, and the shorter expr solution) fail to replicate one property of dirname: dirname of a slash-less path should return a ".". For people still not fed up with this thread, here's an even simpler (and more correct in case of no slash) solution in zsh: $ FILE=/usr/bin/hello $ echo ${FILE:h} /usr/bin $ FILE=aaa $ echo ${FILE:h} . (I indented the whole paragraph above by one space, because who knows what kind of havoc a single dot on a line in an email would cause...) -- Nadav Har'El | Monday, Jun 3 2002, 24 Sivan 5762 [EMAIL PROTECTED] |----------------------------------------- Phone: +972-53-245868, ICQ 13349191 |Spelling mistakes left in for people who http://nadav.harel.org.il |feel the need to correct others. ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]