Question 14 of 20Pro Only
How do you write for and while loops in Bash? Can you show examples of iterating over files and command output?
Sample answer preview
Bash provides several loop constructs, each suited for different situations. The for loop iterates over a list of items. The basic syntax uses the in keyword: for file in *.log; do echo "Processing $file" gzip "$file" done You can also iterate over command output using command…
for loopwhile loopuntil loopread commandbrace expansionfind with while