[NTLUG:Discuss] Shell script help
Rusty Haddock
rusty at fe2o3.lonestar.org
Thu May 11 17:49:56 CDT 2006
. Daniel wrote:
>The trouble is that I can't figure out a way to trim the filename off the
>end of full path list.
>
>So my request to any and all shell script wizards is "how do I trim a
>filename off the end of a pathlist?" e.g. make
>"/home/username/pictures/dsc00054.jpg" into "/home/username/pictures"
I don't use Bash much but this feature, I believe, originally came from
the Korn Shell, which I do use. So once again, off the top of my pointy
little head, I present:
a="/foo/bar/baz/quux"
echo ${a%/[^/]*}
which produced this output:
/foo/bar/baz
Anyone have a better way? As Ross Perot once said, "I'm all ears!" :-)
-Rusty-
--
_____ Rusty Haddock = KD4WLZ = rusty at fe2o3.lonestar.org
|\/ o \ o **Out yonder in the Van Alstyne (TX) Metropolitan Area**
| ( -< O o Microsoft is to software what
|/\__V__/ McDonalds is to gourmet cooking
More information about the Discuss
mailing list