For Loop in Shell
Level 365 keystrokes
for loop iterates over a list of items and executes commands for each.
Shell code
# *.txt expands to the matching names in alphabetical order; the loop runs once per file# If nothing matches, the loop runs once with the literal *.txt1for file in *.txt; do2 echo "Processing: $file" # Quotes keep names with spaces intact; wc -l prints the line count and the name3 wc -l "$file"4doneOutput
Processing: notes.txt
25 notes.txt
Processing: readme.txt
10 readme.txtPractice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Shell code and how often they appear.
"× 4$× 2-× 1;× 1:× 1.× 1*× 1