Re: scripting problem



One way would be to set IFS (Internal Field Separator) to CR before
your loop and restore it after it.

On Jan 28, 2008 2:00 PM, Aaron Bliss <abliss@xxxxxxxxxxxxx> wrote:
Steve,
The easiest way to work around the space problem is to just use tar to
backup the home directory.

Aaron

Steven Buehler wrote:
I am hoping that someone here can help me with this. I am running a little
script that backs up some directories for me. Below is snippet that gets me
into trouble.
---------------------
#!/bin/sh
DIRSTOBACKUP=`/bin/ls -d1 /home/user/*`
for NAMEDIR in ${DIRSTOBACKUP[@]}
do
echo $NAMEDIR
done
---------------------

The problem is that some of the directories have spaces in the names. When
running the for loop, it will take the new NAMEDIR at the space. So "Red
Hat" would end up listing as 2 directories, "Red" and "Hat". Any way around
this?

Thanks
Steve



--
Aaron Bliss
Systems Administrator
SUNY Brockport
(585) 395-2417

--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list




--
Serge Dubrouski.

--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list



Relevant Pages

  • Re: Failing DC
    ... Can I seize this role to a GC server for the ... time being without any issues while I perform metadata cleanup? ... Reboot loop can be virus/spyware etc. also. ... Also need to restore local Administrator and/or Directory ...
    (microsoft.public.windows.server.active_directory)
  • Re: Multiple Database or Full Backup
    ... I had to restore from a bunch of backup files in a directory a while ago, so I write a stored proc which loops ... You can have a similar loop to perform the backup as well. ... >>> the ability to choose multiple databases to back up. ...
    (microsoft.public.sqlserver.server)
  • Re: Get rid of key view loop
    ... but I can't get my key view loop work right. ... I have a dynamic control that adds to responder chain and is ... I had to restore the old next responder. ...
    (comp.sys.mac.programmer.help)
  • Re: DO...LOOP implimentation
    ... the following UNLOOP can drop these return stack items. ... The 1- seems to be there to restore the index to the old value; ... Apparently the Gforth (LOOP) was written ... M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html ...
    (comp.lang.forth)
  • RE: scripting problem
    ... for-loop and then again when you are inside the loop. ... for NAMEDIR in $ ... backup the home directory. ... echo $NAMEDIR ...
    (RedHat)