Date: Wed, 26 Jul 2000 00:42:18 +0300 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: Matt Pillsbury <pillsy@brown.edu> Cc: freebsd-questions@freebsd.org Subject: Re: There must be a better way.... Message-ID: <20000726004218.A34623@hades.hell.gr> In-Reply-To: <20000723192635.A94476@straylight.NONE>; from pillsy@brown.edu on Sun, Jul 23, 2000 at 07:26:35PM -0400 References: <20000723192635.A94476@straylight.NONE>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Jul 23, 2000 at 07:26:35PM -0400, Matt Pillsbury wrote: > I'm running bash, and I recently wanted to change a bunch of filenames > in a directory based on a glob: changing *.JPG to *.jpg . I knew that > > mv *.JPG *.jpg > > wouldn't cut it, but the solution I ultimately used seems really > cumbersome: > > for NAME in *.JPG; do mv $NAME `echo $NAME | sed -e 's/JPG/jpg/'`; done > > There's a more elegant solution, right? This is quite elegant for my taste. Ok, apart from the missing $ in the sed patterns, which I'd write as: sed -e 's/JPG$/jpg/' You can also use basename(1) for something like this: for fname in *.JPG ;do mv ${fname} "`basename ${fname} jpg`" ;done But this only proves that there are many many ways of doing the same thing, when you're on a Unix command line. If what you used worked for you, then why bother to prove it inelegant ? -- "The sun is the same in a relative way, but you're older. Shorter of breath, and one day closer to death." > Pink Floyd, TIME (Dark Side of the Moon) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000726004218.A34623>