SUMMARY : Shell for/foreach pass incorrect varibles to next line (using awk/sed/sort//find)

From: LOEWENTHAL Simon <sloewenthal_at_gemini.edu>
Date: Mon Feb 20 2006 - 13:55:44 EST
Thanks to those who replied and especially thanks to Ken McKinlay who 
told me to change the input field separator:

Et voila:

#!/bin/bash
oldIFS=$IFS
IFS="
"
for mbox in `cat .mailboxlist`;  do
        echo $mbox
        find "/export/home1/fbloggs/$mbox" |cpio -pdm
"/export/mailfolders/$u"
done
IFS=$oldIFS




LOEWENTHAL Simon wrote:

>
>
> Dear all,
>
> Although not strictly an emergency and probably not Sun specific I 
> would appreciate it if you could indulge for a few mins as I've been 
> racking my brains on this one for most of last week, and I had also 
> meant to have had this done by last week.  (I want to use it to move 
> IMAP mail folders between servers.)
>
> Sun's shells won't pass file names from my script with spaces.  With 
> files that have a space in them, when passed as input to the next 
> command, then the command is unable to parse them correctly.  This 
> results in the directory Night\ Logs interpreted as two separate file 
> names.  As you can see I have tried to replace the space character 
> with a delimited one (with sed), but this failed as well.
> I also tested this with Rsync instead of Find, and have had the same 
> result.  I changed to Tcsh and got the same problem.
>
> #!/bin/bash
> for mbox in "`awk -F"/" '{printf("%s\n"),$1}' .mailboxlist |sed -e 
> 's/\ /\\\ /'  |sort -u`"
> do
> echo $mbox
> find /export/home1/fbloggs/$mbox |cpio -pdm /export/mailfolders/$u
> done
>
> Example input for $mbox:  Hire Logs
> Products
> Sent Items
>
>
> This produces:
>
> Hire\ Logs
> find: cannot open Hire\: No such file or directory
> find: cannot open Logs: No such file or directory
> Products
> Sent\ Items
> find: cannot open Sent\: No such file or directory
> find: cannot open Items: No such file or directory
>
> The Products directory is handled correctly.
>
>
>
>
> Any ideas?
> Regards, S
>
>
> -- Nothing fancy and nothing Microsoft
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Mon Feb 20 13:57:30 2006

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:56 EST