Friday, 29 June 2012

Linux bash for loop (repeat command n times)

# one liner:
for i in {1..10}; do echo "$i"; done;

# shell script:

#!/bin/bash
for i in {1..10}
do
  echo "$i"
done

# note: this works in bash, but *not* in sh.

No comments:

Post a Comment