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)
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list