|
| From: | John Kearney |
| Subject: | Re: [Help-bash] BASH quotation question... |
| Date: | Sun, 12 May 2013 04:25:36 +0200 |
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=""> 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
| [Prev in Thread] | Current Thread | [Next in Thread] |