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

bash shell script questions



Hi,

I know this isn't a bash shell script news group, but the fact is I 
can't find one.  Since bash is the default linux shell, I was hoping 
someone could answer a few pretty simple questions.

1.) How do I insert a newline character in a "double-quoted" string?

2.) What is a good method to reassign variables interactively?

3.) [not really part of my shell script..] Is there a way to "scroll" 
within the "Ctrl-r" history file search?  (e.g.: let's say I type 
"Ctrl-r" "filename" and the first thing that comes up is "ls -l 
filename", but I want the previous one when I typed "filename -param1 
-param2".  What key sequence can I use to scroll to the previous use of 
"filename")

I'll include my shell script so you have some idea of what I'm trying 
to do.  Try not to laugh too hard, I'm sensitive about my code. :-)

BTW: I'm a fairly inexperienced shell script writer, so I'd also 
appreciate any helpful remarks.

-------------------------------------------------------------
#!/bin/sh
# David's Backup Utility (dbu) v. 0.1
# David Stern <kotsya@u.washington.edu>
# Tue Jan  6 15:31:01 PST 1998

dbu_list=/root/dbu_list
destination=/backup2
device=/dev/sdb2
copymethod=safecopy2
option=0

echo "" ; echo "David's Backup Utility v. 0.1." ; echo "" ;
while [ $option -ne 7 ] 
do
  echo "   Select a backup operation                                 "
  echo "   --------------------------------------------------------  "
  echo "   1. Change source list.                                    "
  echo "   2. Change backup destination base directory.              "
  echo "   3. Change backup device.                                  "
  echo "   4. Change copy method.                                    "
  echo "   5. Format backup destination device.                      "
  echo "   6. Backup selected files to $destination.                 "
  echo "   7. Quit.                                                  "
  echo "   --------------------------------------------------------  "
  echo "   Source list is $dbu_list                                  "
  echo "   Destination directory is $destination                     "
  echo "   Backup device is $device                                  "
  echo "   Copy method is $copymethod                                " 
; echo "" ;
  read option
  case $option in
    1)
      echo "  Change source list."
      echo "  How do I interactively reassign \$dbu_list ?" ; echo "" ;
    ;;
    2) 
      echo "  Change backup destination base directory."
      echo "  How do I interactively reassign \$destination ?" ; echo 
"" ;
    ;;
    3)
      echo "  Change backup device."
      echo "  How do I interactively reassign \$device ?" ; echo "" ;
    ;;
    4)
      echo "   Change copy method."
      echo "   How do I interactively reassign \$copymethod ?" ; echo 
"" ;
    ;;
    5) 
      echo "   Format backup destination directory." ; echo "" ;
#      mke2fs -v $device
    ;;
    6) 
      echo "   Backup selected files to $destination ."
      for source in `cat $dbu_list`
        do
          if [ -d $destination$source ] # helper
            then 
              echo "   $destination$source exists."
            else
              echo "   $destination$source does not exist."
#             mkdir $destination$source
          fi
          echo "   $copymethod $source ... $destination$source" ; echo 
"" ;
#         $copymethod $source $destination$source
##        echo "" ; echo "ls $source"; echo " ; ls $source ;
        done
    ;;
  esac
done
------------------------------------------------------------
-- 
David Stern

kotsya@u.washington.edu
http://weber.u.washington.edu/~kotsya/



--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: