Add to text file from command line via echo... possible to add to a particular line?[Scanned]
Mikkel L. Ellertson
mikkel at infinity-ltd.com
Thu Jun 29 16:53:13 UTC 2006
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!
More information about the fedora-list
mailing list