The following script doesn't exit on terminal until I hit enter.
Need a script to exit automatically if nothing happens for some seconds. Or when all lines from the file is read.
#!/usr/bin/bash
# Usage: ./tool.sh domains.txt
for addr in $(cat $1);do
host $addr | grep "has address" | cut -d" " -f1,4 &
done
You can make a list of the following addresses to test the script:
google.com
yahoo.com
amazon.com
twitter.com
Notice: I don't want to remove the ampersand "&" from the script.
Thx.
I added exit_code=$!
and wait $exit_code
to my script to solve the problem.