Skip to content

Instantly share code, notes, and snippets.

@moozer
Created January 13, 2016 10:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save moozer/8d53d17680c27ffa0570 to your computer and use it in GitHub Desktop.
Save moozer/8d53d17680c27ffa0570 to your computer and use it in GitHub Desktop.
ping check - simple bash script to ping host list from file
#!/bin/bash
# googling
# "bash read line by line from file"
# gave me this:
# http://stackoverflow.com/questions/10929453/bash-scripting-read-file-line-by-line
# file which contains one hostname or ip per line
FILENAME="hosts"
while IFS='' read -r LINE || [[ -n "$LINE" ]]; do
echo "Checking $LINE"
ping -c 1 $LINE
done < "$FILENAME"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment