added getIps.sh script
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Check if required arguments are provided
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "Usage: $0 <input_file> <output_file>"
|
||||
echo "Example: $0 hosts.txt output.txt"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Input and output files from command line arguments
|
||||
INPUT_FILE="$1"
|
||||
OUTPUT_FILE="$2"
|
||||
|
||||
# Clear previous output
|
||||
> "$OUTPUT_FILE"
|
||||
|
||||
# Process each hostname
|
||||
while read -r host; do
|
||||
# Skip empty lines
|
||||
[[ -z "$host" ]] && continue
|
||||
|
||||
ipv4=$(dig +short A "$host" | head -n 1)
|
||||
ipv6=$(dig +short AAAA "$host" | head -n 1)
|
||||
|
||||
echo -e "$host\t${ipv4:-N/A}\t${ipv6:-N/A}" >> "$OUTPUT_FILE"
|
||||
done < "$INPUT_FILE"
|
||||
|
||||
echo "Done. Results written to $OUTPUT_FILE"
|
||||
Reference in New Issue
Block a user