Mostly Linux & Python syntax notes and hyperlinks.

Tuesday, December 1, 2009

Linux: basename

basename is cool.
Takes out any piece of a filename you'd like to get rid of.  It doesn't take wildcards though.
$ basename ABC_s.vpf _s.vpf
ABC
$ basename AB123 3
AB12
$ basename AB12_34 12*4
AB12_34
It also removes the directory names from the path:
$ basename a/b/c/d/AB12_34
AB12_34
$ basename a/b/c/d/AB12_34 2_34
AB1