This is a discussion on read not preserving double spaces within the Shell scripting forums, part of the Development/Scripting category; Hi, I am trying to rename files but when I get to the "read" command the double spaces in the ...
|
|||||||
| Register | FAQ | Members List | Calendar | Forgotten your password? | Mark Forums Read |
|
|||
|
Hi,
I am trying to rename files but when I get to the "read" command the double spaces in the filenames are not preserved and I end up with a single space and the file rename fails. code: while read LINE do md5hash="$(echo $LINE | cut -c1-16)" filename="$(echo $LINE | cut -c18- |sed 's/\.doc//'|sed 's/^/"/')" fullname="$(echo $LINE | cut -c18- |sed 's/^/\"/'|sed 's/$/"/')" echo mv $fullname $filename-$md5hash-$user\.doc\" >> md5rename done < md5files contents of md5rename file: 138fa9a642ec50fe /home/darc/cache/Customer Service Rx for Sub.doc ffcfcf86b6216988c /home/darc/cache/BERGEN NJADONA march.doc dc21ffbe22ecc83e /home/darc/cache/BERGEN NJADONA June.doc 1ba29dab24f2134e /home/darc/cache/BERGEN NJADONA January.doc bf103cc1895b118d /home/darc/cache/BERGEN NJADONA may.doc thanx, awesome site! |
| Sponsored Links | ||
|
|
|
|||
|
i ended up doing that.
echo "remove whitespace from file names" ls $cachedir | grep -e "[:alnum:]" | \ while read i; do j=`echo -n "$i" | sed -e 's/ /_/g'` mv "$cachedir/$i" "$cachedir/$j" done |
![]() |
| Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| USB Port Blocking / Read only Acces on Windows | rajuk | Windows Xp/2000/2003 server administration | 4 | 06-09-2008 12:13 AM |
| Read one integer from a file, cannot find info | beginer | Shell scripting | 1 | 05-13-2008 06:44 PM |
| Read unix partition table | sweta | Solaris/OpenSolaris | 1 | 02-05-2007 07:51 PM |
| The source seems encrypted and can't be read. Are you try to | raj | Linux hardware | 1 | 01-03-2007 08:59 AM |
| How do I Double KDM (KDE) Login Screens? | tom | Linux software | 1 | 06-09-2005 03:34 PM |