[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Looking for a one line script
- Subject: [ale] Looking for a one line script
- From: fletch at phydeaux.org (Fletch)
- Date: Mon Jun 13 20:32:55 2005
- In-reply-to: <[email protected]> (James Sumners's message of "Mon, 13 Jun 2005 19:31:55 -0400")
- References: <[email protected]>
>>>>> "James" == James Sumners <james.sumners at gmail.com> writes:
James> I need to get the base path of a filename. For example, if
James> I have "/path/to/some/random/file.ext" I need to trim off
James> "file.ext" so that I am left with
James> "/path/to/some/random/". However, the filename could
James> contain spaces and other odd characters. Any suggestions?
Both basename and dirname should handle spaces fine.
freebie:/tmp 625> mkdir -p "foo bar"/baz
freebie:/tmp 626> touch "foo bar"/baz/boink
freebie:/tmp 627> i="$( basename /tmp/foo\ bar/baz/boink )"
freebie:/tmp 628> print "|$i|"
|boink|
freebie:/tmp 629> i="$( dirname /tmp/foo\ bar/baz/boink )"
freebie:/tmp 630> print "|$i|"
|/tmp/foo bar/baz|
--
Fletch | "If you find my answers frightening, __`'/|
fletch at phydeaux.org| Vincent, you should cease askin' \ o.O'
| scary questions." -- Jules =(___)=
| U