[ILUG] Strip first three characters from filename

Colm Buckley colm at tuatha.org
Mon Aug 11 12:45:38 IST 2008


On Mon, Aug 11, 2008 at 7:15 AM, Andrew McGill <glug at lunch.za.net> wrote:

> On Sunday 10 August 2008 23:03:53 Colm Buckley wrote:
> > I hate that
> > nullglob is not set by default; I can't think of any realistic cases
> where
> > keeping the literal glob is the more expected / less surprising
> behaviour.
> Nullglob allows skipping quotes where they are not absolutely required.
>  This
> trick can be used from knowledge and ignorance:
>        ls | sed s/[^0-9]*//g               # until you have a file named
> s/blah/g
>        echo Would you like a cookie?       # until there a file called
> cookie9
>
> After setting nullglob,
>        shopt -s nullglob
> those work "as expected" by someone who understood the bash man page.  As a
> bonus, being able to leaving off quotes saves on finger strain - a limited
> commodity - and allows you to gently learn about wildcards.


Hah; fun times.  Omission of proper quotes around sed regexps and expected
literals is a corporal offence, though.

Colm

-- 
Colm Buckley / colm at tuatha.org / +353 87 2469146



More information about the ILUG mailing list