Skip to content

Instantly share code, notes, and snippets.

@giig982
Forked from moozer/pingcheck.sh
Created July 2, 2024 11:21
Show Gist options
  • Select an option

  • Save giig982/b5c7e70489ce6f920a98b2482ac4bebe to your computer and use it in GitHub Desktop.

Select an option

Save giig982/b5c7e70489ce6f920a98b2482ac4bebe 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