Created
July 13, 2025 11:34
-
-
Save TheCrazyGM/52e6f57d75b864cbf7b5c56e7baaccd5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/bash | |
| # Check if the argument is provided | |
| if [ $# -eq 0 ]; then | |
| echo "Please provide a filename as an argument." | |
| exit 1 | |
| fi | |
| # Read each line of the file | |
| while read -r address; do | |
| # setting timeout, piping error | |
| # Execute ping; if it fails, skip to the next address | |
| result=$(ping -c 1 -W 2 "$address" 2>/dev/null) || continue | |
| # Extract the ping time from the result using cut | |
| time=$(echo "$result" | grep "time=" | cut -d "=" -f 4) | |
| # Print the address and the ping time | |
| echo "$address $time" | |
| done <"$1" | sort -k 2n | column -t -N "Address,Speed" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment