Skip to content

Instantly share code, notes, and snippets.

@daipresents
Last active May 11, 2016 05:56
Show Gist options
  • Save daipresents/b8ecd21e7647f04740239a0ca6dd6f92 to your computer and use it in GitHub Desktop.
Save daipresents/b8ecd21e7647f04740239a0ca6dd6f92 to your computer and use it in GitHub Desktop.
sample loop by bash
array=(
array01
array02
)
for entity in ${array[@]}; do
echo "${entity}"
done
# 実行結果
array01
array02
# 000.txt
line 01
line 02
line 03
for line in `cat 001.txt`; do
echo "${line}"
done
# 実行結果
line
01
line
02
line
03
# 000.txt
line01
line02
line03
for line in `cat 000.txt`; do
echo "${line}"
done
# 実行結果
line01
line02
line03
for textfile in $( ls . | grep .txt$ ); do
echo "${textfile}"
done
# 実行結果
000.txt
001.txt
for textfile in $( ls . ); do
echo "${textfile}"
done
# 実行結果
000.csv
000.txt
001.txt
IP=128.0.0
for i in 1 2 3; do
echo "${IP}.$i"
done
# 実行結果
128.0.0.1
128.0.0.2
128.0.0.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment