RE: scripting problem
- From: "Steven Buehler" <steve@xxxxxxxxxxxx>
- Date: Mon, 28 Jan 2008 15:21:33 -0600
Perfect. Thank You SO MUCH. That did the trick.
Steve
-----Original Message-----
From: redhat-list-bounces@xxxxxxxxxx [mailto:redhat-list-
bounces@xxxxxxxxxx] On Behalf Of Broekman, Maarten
Sent: Monday, January 28, 2008 3:09 PM
To: General Red Hat Linux discussion list
Subject: RE: scripting problem
You could push the ls output through sed to remove the spaces for the
for-loop and then again when you are inside the loop.
DIRSTOBACKUP=`/bin/ls -d1 /home/user/* | /bin/sed -e 's/ /=/g'`
for NAMEDIR in ${DIRSTOBACKUP[@]}
do
DIR=`echo $NAMEDIR | /bin/sed -e 's/=/ /g'`
echo $DIR
done
It's a bit round-about but it'll get around the spaces.
Maarten Broekman
-----Original Message-----
From: redhat-list-bounces@xxxxxxxxxx
[mailto:redhat-list-bounces@xxxxxxxxxx] On Behalf Of Aaron Bliss
Sent: Monday, January 28, 2008 4:01 PM
To: General Red Hat Linux discussion list
Subject: Re: scripting problem
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 alittle
script that backs up some directories for me. Below is snippet thatgets me
into trouble.When
---------------------
#!/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.
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 wayaround
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
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
- Follow-Ups:
- RE: scripting problem
- From: Mertens, Bram
- RE: scripting problem
- References:
- scripting problem
- From: Steven Buehler
- Re: scripting problem
- From: Aaron Bliss
- RE: scripting problem
- From: Broekman, Maarten
- scripting problem
- Prev by Date: Re: scripting problem
- Next by Date: RE: scripting problem
- Previous by thread: RE: scripting problem
- Next by thread: RE: scripting problem
- Index(es):
Relevant Pages
- RE: scripting problem
... The IFS solution is probably a lot safer. ... tar manual. ...
Subject: scripting problem ... for NAMEDIR in $ ... (RedHat) - RE: scripting problem
... for-loop and then again when you are inside the loop. ... for NAMEDIR
in $ ... backup the home directory. ... echo $NAMEDIR ... (RedHat)