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 Thursday, Jun 29th 2006 at 17:37 +0100, quoth Chris Bradford:

=>Paul Howarth wrote:
=>> On Thu, 2006-06-29 at 16:07 +0100, Chris Bradford wrote:
=>>   
=>> > Paul Howarth wrote:
=>> >     
=>> > > On Thu, 2006-06-29 at 07:42 +0100, Chris Bradford wrote:
=>> > >         
=>> > > > [much unimportant stuff deleted]
=>> > > >             
=>> > > How about:
=>> > > 
=>> > > [same here]
=>> > >         
=>> > Paul,
=>> > 
=>> > [not even vaguely relevant]
=>> >     
=>> 
=>>   
=>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

I'm guessing this should have been a new message and not a reply to an old 
message.

As you've already heard

[ $ANSWER = yes -o YES ]

is not the same as 

[ $ANSWER = yes -o $ANSER = YES ]

But what happens if the keyboard monkey would have hit return?

Then the value of ANSWER would have been null, in which case the variable 
would have expanded to null and the shell would have executed

[ = yes -o = YES ] 

which would have been a syntax error. So a better answer would be:

[ "$ANSWER" = yes -o "$ANSER" = YES ]

BUT! baash has something even better. The [ syntax is old. Instead, use 
the double squarebrace syntax.

[[ "$ANSWER" = yes || "$ANSER" = YES ]]

Better, faster, more readable.

-- 
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