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;
}
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
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.
add a comment
|
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
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
add a comment
|
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
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
shell-script shell scripting function
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
add a comment
|
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
add a comment
|
1 Answer
1
active
oldest
votes
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.
add a comment
|
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment
|
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.
add a comment
|
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.
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.
answered Dec 19 '18 at 9:52
Kusalananda♦Kusalananda
166k20 gold badges323 silver badges516 bronze badges
166k20 gold badges323 silver badges516 bronze badges
add a comment
|
add a comment
|
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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