Created
July 30, 2011 23:23
-
-
Save jehiah/1116143 to your computer and use it in GitHub Desktop.
Bash trick #48 while loop reading input from a file
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
#!/bin/sh | |
# this loop uses "read" to parse stdin into variables | |
# stdin is specified at the ending "done" with < input_file, or | |
# in this case, an inline block of text. | |
while read host port; do | |
echo "host $host port $port"; | |
done << EOF | |
google.com 80 | |
google.com 443 | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment