Thanks for your answer. Would you mind helping me to understand how exactly those statements work then.
Is my assumption that "grep s>/dev/null" and "grep r>/dev/null" check whether or not a filename contains an S and an R correct?
So looking over it again, for 2. would this mean it's invoked 15 times too, because it checks every single file.
And as for 3. could it be 7 times, since you only reach the "grep r>/dev/null" part when it found an S in the name (since there are only 7 files with an S)?
---------- Post updated at 09:10 AM ---------- Previous update was at 09:02 AM ----------
Quote:
Originally Posted by
RudiC
Welcome to the forum.
As to your questions:
May I question your reasoning?
a) Where in the script are S or R to be matched? Both upper case?
b) Do you know the meaning of the || operator in shell scripts?
1. How many input items do you have? And, how is the end-of-file detected?
2. Once in the loop, how many times do you think the commands or lists will be executed?
3.and
4. Again: Do you know the meaning of || in shell scripts? How would it influence the execution of the command list?
5. Correct!
a) I believe the filenames were actually all lower case. (As a german, we capitalize names, so that was my mistake when I wrote this down)
b)
|| means we only reach the right side, when the left side is true, iirc. So once it found a filename with an "s", it checks for an "r"?
1. We have 15 items. So it goes through the list of files until every single one was checked?
2. Also 15 times, since it checks every single item for an "s"?
3. 7 times, since we only reach the second part, when we found an item with an "s"
4. 3 times, since we only reach that part, when we found an item with an "s" and an "r"