Need some help with a Shell Script

Hi there,

I'm currently preparing for an exam and came across a shell script.
I can't try this out myself because I don't have access my to my PC right now.

This is the script

myscript.sh
k=0
while read WORT
do
	echo $WORT|grep s>/dev/null || echo $WORT|grep r>/dev/null || let k=$k+1
done
echo $k

The script is then started with the line:

ls | /home/notroot/scripts/myscript.sh

And these are the files in the current directiory: Asprin, Benz, Burroughs, Claremont, Eddings, Doms, Gardner, Lucas, Martin, McKiernam,
Pabst, Pratchett, Schlederer, Tolkien, Vollenbruch

Question now is, which of the files lead to a change of the variable k.
And how often are the following statements invoked:

1."read WORT"
2. "echo $WORT|grep s>/dev/null"
3. "echo $WORT|grep r>/dev/null"
4. "let k=$k+1"
5. "echo $k"

The results I came to are the following:
If I understand the script correctly, k would be increased every time the script comes across a file that contains at least one S and at least one R. So the files Asprin, Burroughs and Schlederer would lead to an increment of the variable k.

As for how often the statements are invoked:

  1. Once
  2. 7 times
  3. 3 times
  4. 3 times
  5. Once

So yeah, I would appreciate it greatly if someone could tell me whether I understood how the script works correctly or not.

Thanks in advance and cheers!

Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.