| seq
| tee
| ping
#!/bin/bash
# 🎨 스타일 정의
bold=$(tput bold)
normal=$(tput sgr0)
green="\033[1;32m"
red="\033[1;31m"
cyan="\033[1;36m"
blue="\033[1;34m"
reset="\033[0m"
function title() { echo -e "${blue}${bold}🔷 $1${reset}"; }
function success() { echo -e "${green}✅ $1${reset}"; }
function error() { echo -e "${red}❌ $1${reset}"; }
function info() { echo -e "${cyan}📡 $1${reset}"; }
# 초기 설정
LOG=ping.log
PREFIX="192.168.0"
START=1
END=254
alive=0
dead=0
# 로그 초기화
> "$LOG"
echo
title "📊 Ping Sweep Report"
echo "🌐 Target Range : ${PREFIX}.1 ~ ${PREFIX}.${END}"
echo "🕒 Started at : $(date '+%F %T')"
echo "📄 Log File : $LOG"
echo "──────────────────────────────────────────────"
# 스캔 시작
for i in $(seq $START $END); do
(
IP="${PREFIX}.${i}"
if ping -c1 -W1 "$IP" &>/dev/null; then
echo "${IP} is alive" >> "$LOG"
success "$IP is alive"
else
echo "${IP} is dead" >> "$LOG"
error "$IP is dead"
fi
) &
done
# 모든 백그라운드 작업 대기
wait
# 결과 요약
echo
title "📋 Summary"
alive=$(grep -c "is alive" "$LOG")
dead=$(grep -c "is dead" "$LOG")
echo -e "✅ ${green}Alive Hosts : $alive${reset}"
echo -e "❌ ${red}Dead Hosts : $dead${reset}"
echo
title "🏁 Done at $(date '+%F %T')"
echo