Jump to content

For loops

From Squishu Wiki

General

  • NB: bash considers all variables to be strings by default, even 69

Syntax

  • this example has a for and a do loo'
for variable in values
do
  statements
done

Examples

for blah in one two 69
do
  echo $blah
done
exit 0
  • Example of for loop with wildcard expansion
  • The parameter list for the for loop is provided by the output of the command in the $()
for file in $(ls f*.sh); do
  lpr $file
done
exit 0