Jacky Li wrote:

I am trying to rename a bunch of files to another name. For example,

picture 1 to picture1
picture 2 to picture2
...

May I know how you can take out the space in old filename? Thank you.

Since you said you have a bunch of them, I suggest this:

# for file in * ; do mv "$file" `echo $file | sed 's/\ //g '` ; done

For example:

   # ls -l
   total 8
   -rw-r--r--    1 root     root            0 Feb 21 17:56 file 2
   -rw-r--r--    1 root     root            0 Feb 21 17:56 picture 1
   -rw-r--r--    1 root     root            0 Feb 21 17:56 this is long

# for file in * ; do mv "$file" `echo $file | sed 's/\ //g '` ; done

   # ls -a
   -rw-r--r--    1 root     root            0 Feb 21 17:56 file2
   -rw-r--r--    1 root     root            0 Feb 21 17:56 picture1
   -rw-r--r--    1 root     root            0 Feb 21 17:56 thisislong


Hope this helps.


--
W | I haven't lost my mind; it's backed up on tape somewhere.
 +--------------------------------------------------------------------
 Ashley M. Kirchner <mailto:[EMAIL PROTECTED]>   .   303.442.6410 x130
 IT Director / SysAdmin / WebSmith             .     800.441.3873 x130
 Photo Craft Laboratories, Inc.            .     3550 Arapahoe Ave. #6
 http://www.pcraft.com ..... .  .    .       Boulder, CO 80303, U.S.A.






-- redhat-list mailing list unsubscribe mailto:[EMAIL PROTECTED] https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to