How to count the number of arguments passed under condition?Keeping the number of files in the folder...

Knights and Knaves: What does C say?

Why has Speaker Pelosi been so hesitant to impeach President Trump?

What is the meaning of first flight and introduction in aircraft production?

What is the difference between increasing volume and increasing gain?

Should I be an author on another PhD student's paper if I went to their meetings and gave advice?

Does the 'java' command compile Java programs?

Principled construction of the quaternions

What does a textbook look like while you are writing it?

Is the "spacetime" the same thing as the mathematical 4th dimension?

Is there a pattern for handling conflicting function parameters?

How is this situation not a checkmate?

How to identify whether a publisher is genuine or not?

Why not add cuspidal curves in the moduli space of stable curves?

What are one's options when facing religious discrimination at the airport?

How to say "respectively" in German when listing (enumerating) things

Avoiding dust scattering when you drill

Can I bring this power bank on board the aircraft?

What's the global, general word that stands for "center tone of a song"?

How to find places to store/land a private airplane?

Phonetic distortion when words are borrowed among languages

French license plates

GPLv3 forces us to make code available, but to who?

Duck, duck, gone!

If I travelled back in time to invest in X company to make a fortune, roughly what is the probability that it would fail?



How to count the number of arguments passed under condition?


Keeping the number of files in the folder constant by deleting old filesshell Script: Sorting files into directories and subdirectoriesHow is it possible to execute a command with an unknown number of arguments in a POSIX shell?Looking for a pattern with conditionsHow to surround xarg's inputs with more arguments?How to count occurrences of each word belonging to a file in all of `n` number of files passed as arguments?How to drop an argument (from the list of arguments) in a shell script?How to convert dynamic shell arguments into URI query?While Loop over a File returning command not found






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{
margin-bottom:0;
}








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 "









share|improve this question

















bumped to the homepage by Community 39 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.












  • 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















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 "









share|improve this question

















bumped to the homepage by Community 39 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.












  • 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












0








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 "









share|improve this question
















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 "






shell-script shell scripting function






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 19 '18 at 12:18







Rania

















asked Dec 19 '18 at 9:17









RaniaRania

61 bronze badge




61 bronze badge






bumped to the homepage by Community 39 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.









bumped to the homepage by Community 39 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 39 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.










  • 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














  • 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








1




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





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










1 Answer
1






active

oldest

votes


















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 passedn' "$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.






share|improve this answer



























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });















    draft saved

    draft discarded
















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f489867%2fhow-to-count-the-number-of-arguments-passed-under-condition%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    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 passedn' "$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.






    share|improve this answer






























      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 passedn' "$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.






      share|improve this answer




























        0














        0










        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 passedn' "$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.






        share|improve this answer













        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 passedn' "$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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 19 '18 at 9:52









        KusalanandaKusalananda

        166k20 gold badges323 silver badges516 bronze badges




        166k20 gold badges323 silver badges516 bronze badges


































            draft saved

            draft discarded



















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f489867%2fhow-to-count-the-number-of-arguments-passed-under-condition%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

            Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

            Ciclooctatetraenă Vezi și | Bibliografie | Meniu de navigare637866text4148569-500570979m