0

I'm trying to create a shell script taking as argument a series of averages and assign for each note an observation, example :

There are 5 averages that are introduced.
There are 2 notes that are: pretty good.
There are 3 notes that are: well
....

for i in $@
if [[ $# -ge 16 ]]; 
then 
    let j++
    echo " there are ${#j} notes that are : pretty good "
elif [[ $# -ge 14 ]]; 
    let k++
    echo " there are ${#k} notes that are : good "
  • 1
    Please try to format your question by editing it, using the formatting tools provided by U&L. If possible, code that's running would be helpful. Also, I am having a difficult time understanding your question. Can you maybe rephrase it? – OneK Dec 19 '18 at 9:25
  • Please don't post images of text or code! It makes it impossible to copy the code to an editor, and the reader can't control the colors, the font etc. That JPG with serious compression artifacts is especially hard to read. Just copy and paste the code itself, and make sure to format code in code blocks (see the editing help) – ilkkachu Dec 19 '18 at 10:01
0

Count your things first, then separately report the result:

#!/bin/bash

for a do
    if (( a >= 10 && a < 12 )); then
        pass=$(( pass + 1 ))
    elif (( etc. for the other conditions ))
    fi
done

printf '%d passed\n' "$pass"

There is no need to test on $# as the loop (if written as above) would not execute at all if no arguments were passed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.