Skip to content

Instantly share code, notes, and snippets.

@Bost
Last active July 31, 2017 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bost/52ec4d8de3b5956abdb455284a79e106 to your computer and use it in GitHub Desktop.
Save Bost/52ec4d8de3b5956abdb455284a79e106 to your computer and use it in GitHub Desktop.
bash: for-loop
#!/usr/bin/env bash
# Debugging
# set -x
# Stop on error
set -e
# Exit if variables are not set (recommended)
set –u
tstp() {
date +"%Y-%m-%d %H:%M:%S,%3N"
}
# array=( $(find ./ -name '*.txt') )
array=( $(ls) ufo "uff ooo")
# array=( one two three )
echo "Array size (length):" ${#array[@]}
for i in "${array[@]}"; do
echo $(tstp) ${i}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment