LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] How do I mv a bunch of files w/ a RE?

[ILUG] How do I mv a bunch of files w/ a RE?

Dave Neary dave.neary at palamon.ie
Mon Jul 2 11:11:56 IST 2001


David Golden wrote:
> 
> Braun Brelin wrote:
> 
> >Hi folks,
> >
> >I have a bunch of files in a directory of the following format:
> >
> >
> >a001.html
> >a002.html
> >a003.html
> >
> >I'd like to find a single 'mv' command to change these files from axxx.html
> >to bxxx.html.
> >
> >Obviously, commands like 'mv a???.html b???.html' don't work.
> >I'd prefer a single line shell command rather than some sort of foreach if
> >possible.
> >
> >Thanks,
> >
> if you have a load of files called a1.html, a2.html, a3.html, etc.,
> the above command will change them all to b1.html, etc.
> Note that the s/^a/b/ is regular-expression-ese,
> and is a whole topic in itself... the s means "switch"
> ^a means "an 'a' character at the start of the input"
> and b is, well, b...

For a shell solution, 
for i in a*.html; do
  mv $i b${i#a};
done

Cheers,
Dave.

-- 
David Neary,               E-Mail dave.neary at palamon.ie
Palamon Technologies Ltd.  Phone +353-1-634-5059




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell