Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Simple conditional yields too many responses Post 303030477 by Xubuntu56 on Monday 11th of February 2019 11:45:22 AM
Old 02-11-2019
@joeyg--I wanted a single response, either "Yes, that is a bird." or "That is not a bird."
@vbe--I tried something else, but unfortunately it appears I need a stronger hint! Now, it works correctly for "duck", but does nothing for the other two birds, nor does it do anything for an incorrect response.
Code:
#!/bin/bash
# bird
read -rp "Enter name of a bird   "
REPLY=$REPLY
birdname="duck sparrow hawk"

for i in $birdname
do
     if [[ "$REPLY" = "$i" ]]; then
             echo "Yes, that is a bird."
     fi
     exit
     if [[ ! "$REPLY" = "$i" ]]; then
         echo "That is not a bird."
      fi
done

results:

Code:
:~/bin$ bird
Enter name of a bird   duck
 Yes, that is a bird.


:~/bin$ bird
 Enter name of a bird   sparrow
:~/bin$ 


:~/bin$ bird
  Enter name of a bird   hawk
:~/bin$ 


:~/bin$ bird
 Enter name of a bird    spaniel
:~/bin$

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

ping to machine and count responses

if i wanted to ping all the machines in a given directory (/etc/hosts) and return a total count of responses how would i go about scripting that? complete newbie...so be gentle if ; then //$1 = /etc/hosts cd "$1" //this puts me into the directory i need...but how do i send ... (2 Replies)
Discussion started by: trostycp
2 Replies

2. Shell Programming and Scripting

How to automate responses

I would have searched for this but I couldn't really think of what to use for the search text... I've got a situation where I need to automate responses to an executable when running it from a script so that it can be made into a job the operators don't have to interact with. When I run it... (2 Replies)
Discussion started by: djp
2 Replies

3. Linux

How do I capture responses from the chat command?

Unfortunately googling the word 'chat' gives you zebedee billion responses that relate to everything and few of them refer to the linux chat command. I've read the man page and found a couple of examples but can't see how to do this. I want to query the modem for it's manufacturer, product id... (8 Replies)
Discussion started by: Bashingaway
8 Replies

4. Shell Programming and Scripting

Using AWK to Calculate Correct Responses

Hello, I am trying to count how many times a subject makes a correct switch or a correct stay response in a simple task. I have data on which condition they were in (here, labeled "IMAGINE" and "RECALL"), as well as whether they made a left or right button response, and whether the outcome was... (5 Replies)
Discussion started by: Jahn
5 Replies

5. Shell Programming and Scripting

Simple awk conditional one-liner

Hello, I'm looking for an awk one-liner that prints the first two data fields, then contains a conditional where if $3>$4, it prints $3-$4. Otherwise, it prints $3. Example: Data file: 123,456,999,888 333,222,444,555 654,543,345,888 444,777,333,111 Output: 123,456,111 333,222,444... (2 Replies)
Discussion started by: palex
2 Replies

6. Infrastructure Monitoring

SNMP responses failing under high system load

Greetings, I've got a Zenoss v2.5 server monitoring a large video encoding farm. Needless to say, these systems are under high bandwidth and CPU utilization the majority of the time. What I'm running into is that, occasionally, these systems will fail to respond to a standard SNMP request,... (1 Reply)
Discussion started by: Karunamon
1 Replies

7. IP Networking

DNS: Dig returns different responses...

Hey everyone, Okay, so I've been having some fun with the dig command, and wanted to dig my old school. Two questions came up from this. So I: dig @8.8.8.8 +recurse njcu.edu ANY and the result is about 8 records, including the SOA record. One of them is this weird TXT record, and the other is... (1 Reply)
Discussion started by: Lost in Cyberia
1 Replies

8. UNIX for Dummies Questions & Answers

Cp via NFS vs. scp yields unexpected difference

I have two Linux machines, Linux1 and Linux2. They both have two NFS mounts. We'll call them /scratch1 and /scratch2. And they both reside on the same NetApp filer. If I copy a 512Mb file from /scratch1 to /scratch2 while logged on Linux1 it takes 40s. However if I scp this file from... (1 Reply)
Discussion started by: crimso
1 Replies

9. Shell Programming and Scripting

Searching a file - and assigning responses to variables (or something)

So first: Sorry if the title is confusing... I have a script I'm writing with a file with several names in it (some other info - but it's not really pertinent...) - I want to be allow the user to delete certain records, but I ran into a problem I'm not sure how to go about fixing. If I were... (6 Replies)
Discussion started by: sabster
6 Replies
KMK(1)							simple makefiles for complex tasks						    KMK(1)

NAME
kmk - framework for writing simple makefiles for complex tasks SYNOPSIS
kmk [OPTIONS] DESCRIPTION
kmk and its helper tools are an extension to GNU make to ease writing portable Makefile. The goals of the kBuild framework: - Similar behavior cross all supported platforms. - Flexibility, don't create unnecessary restrictions preventing ad-hoc solutions. - Makefile can very simple to write and maintain. There are four concepts being tried out in the current kBuild incaration: - One configuration file for a subtree automatically included. - Target configuration templates as the primary mechanism for makefile simplification. - Tools and SDKs for helping out the templates with flexibility. - Non-recursive makefile method by using sub-makefiles. kBuild does not provide any facilities for checking compiler/library/header configurations, that's not in its scope. If this is important for your project, check out the autoconf tool in the GNU build system. It is possible to use kBuild together with autoconf if you like, but you might just as well use the full GNU package. On Debian systems, the kBuild binaries can be found in /usr/bin and its data files in /usr/share/kBuild. SEE ALSO
make(1) HOMEPAGE
More information about kBuild project can be found at <http://svn.netlabs.org/kbuild/>. AUTHOR
kBuild was written by Knut St. Osmundsen <bird-kBuild-spam@anduin.net>. This manual page was written by Daniel Baumann <daniel@debian.org>, for the Debian project (but may be used by others). 0.1.98svn2318 2009-04-09 KMK(1)
All times are GMT -4. The time now is 05:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy