On 11/7/05, m ike <[EMAIL PROTECTED]> wrote:
> On 11/7/05, Carl Lowenstein <[EMAIL PROTECTED]> wrote:
> > On 11/7/05, m ike <[EMAIL PROTECTED]> wrote:
> > > > n=0; for old in `ls -1 *.txt`; do ((n+=1)); s=`printf '%04d' $n`;
> > > > new=${old/.txt/--$s.txt}; mv -vi $new; done
> > >
> > > some nifty alterations for GNU bash, version 3.00.0(1)-release
> > > (i586-suse-linux)
> > >
> > > adding a percent symbol, as in
> > >
> > > ${old/%.txt/--$s.txt};
> > >
> > > forces matching at the end
> >
> > I suppose this is good in case you have files named foo.txt.txt
>
> google returns remakably few, for "txt txt" -"txt txt txt"
>
> I'd be interested in knowing how to generalize:
>
> ls -1d foo[123].ps
>
> (which would list foo1.ps, foo2.ps, foo3.ps). The generalization
> would be something like
>
> ls -1d foo.[html,css,js]
>
> to list foo.css, foo,js, and foo.html, but not foo.js~ or
> foo.js-2005-10-23-01
>
> The way I know is
>
> shopt -s extglob
> ls -1d foo.+(html|css|js)
Isn't this just brace expansion, pioneered in csh but also present in
bash and ksh.
$ ls -1d foo.{html,css,js}
Works for me. Alternatively:
$ ls foo.* | grep -E '(css|html|js)$'
carl
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list