Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
- The problem statement, all variables and given/known data:
In the currenty directory are the following files: asprin, benz, burroughs, claremont, eddings, doms, gardner, lucas, martin, mckiernam,
pabst, pratchett, schlederer, tolkien, vollenbruch
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"
- Relevant commands, code, scripts, algorithms:
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 started with the following line:
ls | /home/notroot/scripts/myscript.sh
- The attempts at a solution (include all code and scripts):
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:
- 15 times
- 7 times
- 3 times
- 3 times
- Once
Just wanna know whether I understood the script correctly.
Thanks in advance.
- Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
University of Applied Sciences, Trier, Germany, Systemadministration
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).