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

[SOLVED] Re: need help with bash command



On Thu, 20 Nov 2008 13:28:17 -0200
Eduardo M KALINOWSKI <eduardo@kalinowski.com.br> wrote:

> tôba escreveu:
> > Hello,
> >
> > Can you help me with a bash command?
> > I a directory, I want to extract with a command line for jpg name
> > files. I have a lot of:
> >
> > icon_3620_0_1.jpg
> > icon_3616_0_1.jpg
> > icon_3563_0_1.jpg
> >
> > I want to extract the number betwen icon_*_0_1.jpg AND I want to use
> > the entire filename too in the same command.
> >
> > The goal is to create a directory called 3620 and move the
> > icon_3620_0_1.jpg file into this directory.
> >
> > So, I did like this for test:
> >
> > # for a in `ls | sed -e s'/_/ /g' | awk '{print $2}'`; do echo
> > icon_$a_0_1.jpg; done
> >   
> 
> Try icon_${a}_0_1.jpg
> 
> Why it works is left as an exercise for the reader. (Hint: man bash).


Ok,
Thank you Eduardo, it works,

Regards,

--
Tôba


Reply to: