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 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



Relevant Pages

  • scripting problem
    ... script that backs up some directories for me. ... Below is snippet that gets me ... for NAMEDIR in $ ...
    (RedHat)
  • Re: space char shell script problem
    ... If I want to run the script; ... What is the best way to deal with this type of space problem in the shell? ... Depending on what your script is doing, I would use an intermediate file and awk. ... So depending on what your original script was doing, this method may work for you. ...
    (freebsd-questions)
  • Re: Formmail cgi problem
    ... However, there is a better, more secure, script at ... "kyle" wrote in message ... > formmail script they provided. ... > space problem can't be fixed but I could use a different ...
    (microsoft.public.frontpage.programming)
  • Re: Formmail cgi problem
    ... >Microsoft FrontPage: ... >| I am using a form script and everything works how I ... space problem can't be fixed but I could use a different ...
    (microsoft.public.frontpage.programming)