[PLUG] A shell scripting lesson

Jeme A Brelin jeme at brelin.net
Mon Jun 10 18:55:37 UTC 2002


On Mon, 10 Jun 2002, Rich Shepard wrote:
>   I know that I can replace file suffixes with a loop that renames files one
> by one as the variable is incremented. If I want to change one character in
> a series of file names, can I do this all in one fell swoop with a loop?
> 
>   Specifically, I have a bunch of digital images files named, for example,
> 0606_*.jpg, and I want to change them all to be 0605_*,jpg.

for file in 0606_*; do mv $file `echo $file|sed -e 's/^0606/0605/'`; done

J.
-- 
   -----------------
     Jeme A Brelin
    jeme at brelin.net
   -----------------
 [cc] counter-copyright
 http://www.openlaw.org





More information about the PLUG mailing list