help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] BASH quotation question...


From: Barry Smith
Subject: Re: [Help-bash] BASH quotation question...
Date: Sat, 11 May 2013 23:51:07 -0400

John:

Thank you for the pointer.

I remembered immediately the brackets when I saw them, but I'll have
to refresh my memory by looking through some of my notes on them

Thank you for the pointer.

Peace,
--
Barry Smith
c 704-497-4217
e address@hidden
skype bnsmith001_gmail
w1 http://bit.ly/l8QJup
w2 http://scs-llc.info/


On Sat, May 11, 2013 at 10:25 PM, John Kearney <address@hidden> wrote:
> you need
>
> STARTDIR="/cygdrive/c/Users/
> Barry/Douments"
> cd "$STARTDIR"
>
> SRC="Work_Week_2012.09.12"
> TARGET="Work\ Week\ 2012.09.12"
> mkdir "$TARGET"
>
> i.e. quote the variables when you use them.
>
> and its not a bad idea to get into the habit of writting it more like this
>
> mkdir "${TARGET}"
>
>
> cheers
>
>
>
> On Sat, May 11, 2013 at 9:38 PM, Barry Smith <address@hidden> wrote:
>>
>> I just found this "help list" mentioned on
>> http://tiswww.case.edu/php/chet/bash/bashtop.html . There were no
>> instructions on subscribing, so I haven't subscribed, and might never
>> know if there are followup responses.  Please reply to the list
>> archive, and CC me on responses.
>>
>> HELP please, oh gods of bash!
>> Thank you in advance.
>>
>> My environment is Windows 7 Home Premium / cygwin / Bash
>> 4.1.10(4)-release.
>>
>> I am writing a "simple" bash script to set up for a backup to DVD, but
>> am having problems setting variables to directory names with spaces,
>> and then using the variables in mkdir / cp / mv / rm / md5sum
>> commands.
>>
>> Here is the nuts and bolts of the second script that does a md5sum,
>> cp, check after cp, then rm.  I have coded an exit that I will move
>> down the script as I test.
>>
>> Current logic fail -- the "mkdir" is creating multiple directories
>> (due to the spaces in the name), not just ONE directory with spaces in
>> the directory name.
>> ---
>> #!/bin/bash
>> # Proper header for a Bash script.
>>
>> STARTDIR="/cygdrive/c/Users/Barry/Douments"
>> cd $STARTDIR
>>
>> SRC="Work_Week_2012.09.12"
>> TARGET="Work\ Week\ 2012.09.12"
>> mkdir $TARGET
>>
>> # FLOATING EXIT
>> exit # The right and proper method of "exiting" from a script.
>>      # A bare "exit" (no parameter) returns the exit status
>>      #+ of the preceding command.
>> # FLOATING EXIT
>>
>> cd $SRC
>>
>> FILE=dvd.md5
>> if [ -f $FILE ];
>> then
>>    echo "2-- EXISTS File $FILE in $SRC"
>>    echo "3-- REMOVE"
>>    # rm -f $FILE
>> else
>>    echo "4-- MISSING File $FILE in $SRC"
>> fi
>>
>> md5sum ./* > dvd.md5
>>
>> md5sum -c dvd.md5
>>
>> cd ..
>>
>> cp -Rf $SRC/* $TARGET/
>>
>> cd $TARGET/ && md5sum -c ./dvd.md5 && cd ..
>>
>> rm -Rf ./$SRC/*
>> rmdir ./$SRC/
>> ---
>>
>>
>>
>> --
>> Barry Smith
>> c 704-497-4217
>> e address@hidden
>> e address@hidden
>> e address@hidden
>> e address@hidden
>> e address@hidden
>> skype bnsmith001_gmail
>> w1 http://bit.ly/l8QJup
>> w2 http://scs-llc.info/
>> DUNS 83-099-9384
>> EIN 27-4523550
>>
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]