Explore BrainMass

Shell scripting: Loops and Redirection

This content was STOLEN from BrainMass.com - View the original, and get the solution, here!

Give brief answers for the following Bash questions.

1) Does filename generation occur on variable assignment?

2) In the traditional Bourne Shell, does a sub-shell get created when there is I/O redirection to a loop?

3) Will the following command always correctly loop through each of the positional parameters?

for I in "$*"
echo $I

4) Will the following loop always execute only once?

for I in "$@"
echo $I

5) Will the following command sometimes execute once?

for I do echo $I done

6) Does a while loop always execute at least once?

© BrainMass Inc. brainmass.com September 23, 2018, 8:59 am ad1c9bdddf - https://brainmass.com/computer-science/web-design/shell-scripting-loops-and-redirection-152462

Solution Preview

1) It can happen, depending upon the right hand side of the assignment. For example, an assignment like following will create a file during the variable ...

Solution Summary

Solution also gives reasons/examples (except in case of 2nd question).