Reputation: 71
I'm using the following command to check the whois information from a list of domains in a text file and then output any lines that contain an email to a new file:
for i in $(cat testdomains.txt); do whois $i| egrep [a-zA-Z0-9]@[a-zA-Z0-9]\.[a-zA-Z0-9]; done >> results.txt
Is there any way to speed this up by checking more than one domain at a time? For example, right now it is going from one domain to the next checking the information. Is there anything I could change in the command to make it check 50 domains at a time?
Upvotes: 0
Views: 4057
Reputation: 185161
With &
, you can run any command in background (so in parallel) :
for i in $(< testdomains.txt); do
whois "$i" | egrep '[a-zA-Z0-9]@[a-zA-Z0-9]\.[a-zA-Z0-9]' &
done >> results.txt
&
at the end of a command, e.g. command args &
, the shell executes the command in the background in a subshell. The shell does not wait for the command to finish, and the return status is 0. Pid of the last backgrounded command is available via the special variable $!
&
do a fork(2)
in the backgroundUpvotes: 3