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]

 



Jeff Vian wrote:
On Thu, 2006-06-29 at 12:18 -0500, Les Mikesell wrote:
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 ]
Chris,
the problem is here ^^^^^^^^^^^^
   if [ $ANSWER = "yes" -o $ANSWER = "YES" ]
would likely work.
Note that $ANSWER is a string and must be compared to a string value.
    in this context "yes" is a string but yes is not a string.
You also must make the comparison test in each case, both before and
after the -o above. Your construct would ask " does $ANSWER = yes
evaluate to true?"  OR "is YES true?".  This is two different questions
and does not get what I think you intended as a result.

Les' answer below would also accept a single key response.
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


Thanks everyone for your help, I've gone with the above option. Really grateful for all you
reply's though :)

-Chris


This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux