Bash Help: Renaming all files in a Directory

Todd Zullinger tmz at pobox.com
Sat Jul 22 02:20:23 UTC 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thom Paine wrote:
>>
>>A little while loop would be one way to do this:
>>
>>ls "Family Pic"*.jpg | while read i; do mv "$i" $(echo $i | tr " " _)
>>
> 
> 
> I tried this command and it gives me a> prompt and sits there. Am I
> doing something wrong?
> 
> And thanks to all the replies.

Tonight's not my night.  There should be a "; done" at the end.  As in

ls "Family Pic"*.jpg | while read i; do mv "$i" $(echo $i | tr " " _); done

But as Patrick and Mikkel pointed out, the for loop would work and
that's less typing. :)

- -- 
Todd        OpenPGP -> KeyID: 0xD654075A | URL: www.pobox.com/~tmz/pgp
======================================================================
Teach a man to make fire, and he will be warm for a day.  Set a man on
fire, and he will be warm for the rest of his life.
    -- John A. Hrastar

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (GNU/Linux)
Comment: When crypto is outlawed bayl bhgynjf jvyy unir cevinpl.

iG0EARECAC0FAkTBi2cmGGh0dHA6Ly93d3cucG9ib3guY29tL350bXovcGdwL3Rt
ei5hc2MACgkQuv+09NZUB1qK9wCfWcu+GhCjZrEQIG78ULRRn0s+8KIAmwazFMKk
YQ5QTm9J+DbiLSPGSXuk
=co/d
-----END PGP SIGNATURE-----




More information about the fedora-list mailing list