Re: Add to text file from command line via echo... possible to add to a particular line?[Scanned]

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

 



On Thu, 2006-06-29 at 17:37 +0100, Chris Bradford wrote:
> >   
> Any ideas as to why this:
> 
> echo -n "Would you like to configure SophosAV: (type yes/no) "
> read ANSWER
> 
> if [ $ANSWER = yes -o YES ]
> then
>     echo 'good'
>     echo 'Enter script to run here....'
> 
> else
>     echo 'bad'
>     echo 'Carry on to next part of current script...'
> fi
> 
> Does not work?

You might find this construction easier:

read ANSWER

case $ANSWER
 in
 [Yy]*)
    echo 'good'
    echo 'Enter script to run here....'
 ;; 
 *)
   echo 'bad'
    echo 'Carry on to next part of current script...'
 ;;
esac

It's a little easier to write and much easier to add additional choices.
Note that unlike C, you don't fall through after a match.

-- 
  Les Mikesell
   lesmikesell@xxxxxxxxx

 


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux