вот мой код:
Код: Выделить всё
is_valid_domain() {
local domain="$1"
if host "$domain" &> /dev/null; then
return 0
else
return 1
fi
}
if [ "$#" -eq 1 ]; then
filename="$1"
# Check if the file exists
if [ ! -f "$filename" ]; then
echo "Error: File '$filename' not found."
exit 1
fi
#if the file exists
#Process each domain in the file
while IFS= read -r domain_name; do
if is_valid_domain "$domain_name"; then
echo -e "Domain name: $domain_name\nIP Address: $(host "$domain_name" | awk '/has address/ {print $4}')"
else
echo "No domain names found"
fi
done < "$filename"
Подробнее здесь: https://stackoverflow.com/questions/783 ... ash-script
Мобильная версия