TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:7564] more bash



 if you get info back from a command, and want to string compare the
>first 3 characters, don't tell me I have to go do this in Perl or
>something, do you?
>
>day=`date`
>if [ day = "Fri *" ]; then
>.
>.
>.
>
>doesn't work, nor does defining a Fri_str to compare it to.  I promise
>I'll get the book, but if someone can 'splain this to me, my family can
>have me back tonight...

Try this:

  day=`date | cut -f 1 -d " "`
  if test $day = "Fri"; then
    do stuff;
  elif test $day = "Sat"; then
    do stuff;
  .
  .
  .
  else
    default do stuff;
  fi

Or this:

  day=`date | cut -f 1 -d " "`
  case "$date" in
  Fri)
    do stuff;
  Sat)
    do stuff;
  .
  .
  .
  *)
    default do stuff;
  esac


nathan