View Single Post
Join Date: Dec 2008
Posts: 64
Reputation: cfajohnson is an unknown quantity at this point 
Solved Threads: 13
cfajohnson cfajohnson is offline Offline
Junior Poster in Training

Re: change file names

 
0
  #6
Jan 25th, 2009
Originally Posted by bugmenot View Post
ls *.done | while read line ; do mv $line $(basename $line .done) ; done

You don't need ls.

You don't need basename (an external command).

Your script will fail if any filenames contain spaces, because you haven't quoted "$line" and "$(basename $line .done)"

Shell Scripting Syntax (Toggle Plain Text)
  1. for file in *.done
  2. do
  3. mv "$file" "${file%.done}"
  4. done
Last edited by cfajohnson; Jan 25th, 2009 at 10:09 am.
Chris F.A. Johnson
http://cfajohnson.com
Reply With Quote