Skip to content

Instantly share code, notes, and snippets.

@jehiah
Created July 30, 2011 23:23
Show Gist options
  • Save jehiah/1116143 to your computer and use it in GitHub Desktop.
Save jehiah/1116143 to your computer and use it in GitHub Desktop.
Bash trick #48 while loop reading input from a file
#!/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