commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
Useful for grepping an IP range from the maillog. When for instance dealing with a spam-run from a specific IP range, or when errors occur from or to a specific IP-range.
In the example above the IP range 188.8.131.52/10 (184.108.40.206 - 220.127.116.11)
To grep the IP range 18.104.22.168/19 (22.214.171.124 - 126.96.36.199) from the maillog:
egrep '124\.217\.2(2[4-9]|[0-9]|5[0-5])' -J /var/log/maillog*
NOTE: the location of the maillog may vary based upon operating system and distribution.
There are 9 alternatives - vote for the best!
If you can do better, submit your command here.
You must be signed in to comment.