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]

 



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?
> 
> Thanks,
> 
> -Chris
> 
> 
> This message has been scanned for viruses by BlackSpider MailControl -
> www.blackspider.com
> 
Change the if statement to
if [ $ANSWER = yes -o $ANSWER = YES ]

The way you have it is testing if $ANSWER = yes is true or if YES is
true, not if $ANSWER = yes or $ANSWER = YES is true.

Oh yes, a better way to do it might be:
if [ $(echo $ANSWER | tr a-z A-Z) == YES ]

This will catch yes, Yes, YES, etc...

Mikkel
-- 

  Do not meddle in the affairs of dragons,
for thou art crunchy and taste good with Ketchup!


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

  Powered by Linux