The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 02-15-2008
fimblo fimblo is offline
Registered User
  
 

Join Date: Feb 2008
Location: stockholm sweden
Posts: 31
how bout this:

Code:
for file in $(find . -type f -iname '*.img'); do
  mv $file ${file/img/iso}
done
This doesnt take filenames nor directories with whitespaces in them, to adapt the above to that, do:

Code:
save_ifs=$IFS ; IFS='
'
for file in $(find . -type f -iname '*.img'); do
  mv "$file" "${file/img/iso}"
done
IFS=$save_ifs
hope this helps
cheers

EDIT: This works for bash, but if I remember correctly the default shell on macosX is bash...