Last active
May 11, 2016 05:56
-
-
Save daipresents/b8ecd21e7647f04740239a0ca6dd6f92 to your computer and use it in GitHub Desktop.
sample loop by bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array=( | |
array01 | |
array02 | |
) | |
for entity in ${array[@]}; do | |
echo "${entity}" | |
done | |
# 実行結果 | |
array01 | |
array02 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 000.txt | |
line 01 | |
line 02 | |
line 03 | |
for line in `cat 001.txt`; do | |
echo "${line}" | |
done | |
# 実行結果 | |
line | |
01 | |
line | |
02 | |
line | |
03 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 000.txt | |
line01 | |
line02 | |
line03 | |
for line in `cat 000.txt`; do | |
echo "${line}" | |
done | |
# 実行結果 | |
line01 | |
line02 | |
line03 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for textfile in $( ls . | grep .txt$ ); do | |
echo "${textfile}" | |
done | |
# 実行結果 | |
000.txt | |
001.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for textfile in $( ls . ); do | |
echo "${textfile}" | |
done | |
# 実行結果 | |
000.csv | |
000.txt | |
001.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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