[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: 38

On 2010-08-28 20:54:42 +1000, Brian May wrote:
> When the solution is easy I don't see why we don't just do it.
> brian@andean:~$ i="cat's meow.tar.gz"
> brian@andean:~$ echo "`basename "$i" .tar.gz`"
> cat's meow
> (yes, the nested quotes don't seem to matter)

They matter if you have consecutive spaces, for instance.
And this is not sufficient:

xvii:~> i="--foo  bar.tar.gz"
xvii:~> echo "`basename "$i" .tar.gz`"
basename: invalid option -- '-'
Try `basename --help' for more information.

You need:

xvii:~> echo "`basename -- "$i" .tar.gz`"
--foo  bar

Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)

Reply to: