Skip to content

Unix Loops

Kyle Coberly edited this page Oct 1, 2017 · 3 revisions

Loop Structure

[Loop Header]
do
    # Loop Body, reference iterator with $i
done

Loop Headers

for i in *
for i in $(ls -l)
for ((i=0; i<5; i++))
while [ $some_variable -lt 10 ]
until [ $some_variable -gt 10 ]

Loop Control

  • continue 3 - How many loops you want to jump up
  • break 3 - How many loops you want to jump up
  • wait [process_id]
  • exit
  • sleep 10 - (seconds)
Clone this wiki locally