PrintLogo

Substring Replacement With BASH




If you need to rename a substring of a bunch of filenames to something else, use a command like this:

 
for i in server*.html; do mv $i ${i/server/workstation} ; done

This changes all serverblah.html files to workstationblah.html. For more on BASH, see the BASH Manpage.



This article comes from NetAdminTools:
http://www.netadmintools.com/

The URL for this story is:
http://www.netadmintools.com/art545.html

Copyright 1997-2007 NetAdminTools.com. Read our Terms of Use.