Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
awk '{print $2,$3}' would print out the source and destination addresses of your first line. You could write a little script with awk, Perl, or Python to do some reporting if you wanted to.
Please explain a little bit more clearly or more precise.The excerpt info above is in a file.gz. Now,would awk'{print $2,$3}'<file.gz> work? And,if you cant write a script,is there another way to get all the IPs out.
Thanks a lot. Here's what the first command gave me when I run it against the .gz file:
27 14:25:55
27 14:25:55
27 14:25:58
27 14:26:08
27 14:26:10
27 14:26:10
27 14:26:11
27 14:27:13
27 14:27:15
Below is what the second command gave me.
27 14:25:55
27 14:25:55
27 14:25:58
27 14:26:08
27 14:26:10
27 14:26:10
27 14:26:11
27 14:27:13
Im not quite sure what is the "27"?? Im assuming that "14:27:13" the IP address. Correct? Given the excerpt above.Sounds more like a time stamp..isnt it?
Thanks a lot. Here's what the first command gave me when I run it against the .gz file:
27 14:25:55
27 14:25:55
27 14:25:58
27 14:26:08
27 14:26:10
27 14:26:10
27 14:26:11
27 14:27:13
27 14:27:15
Below is what the second command gave me.
27 14:25:55
27 14:25:55
27 14:25:58
27 14:26:08
27 14:26:10
27 14:26:10
27 14:26:11
27 14:27:13
Im not quite sure what is the "27"?? Im assuming that "14:27:13" the IP address. Correct? Given the excerpt above.Sounds more like a time stamp..isnt it?
looks like a timestamp, guessing the "27" is the 27th day of the month.
You may need to adjust the "$numbers" that are in those commands.
There are a ton of tutorials on how to use sed, and awk online. I would suggest reading over a few of them just to get a basic idea of how these commands work as they can be quite helpful.
Two things. You wont be able to run awk on a gzip file. Either uncompress it first, or use zcat on the file, then pipe it into the awk command. Also you didn't put a space between the end of the awk command and the file name.
Eureka!! I found it..this command gives me the ip address out of the log file.Thanks a lot for all your help.
zcat anda.log.gz | sed 's/SRC=\|DST=//g' | awk '{print $12"\t"$13}' | more
This is just a portion of the output that I got:
.............. ...........
192.150.249.87 11.11.11.89
211.168.230.94 11.11.11.70
211.168.230.94 11.11.11.72
211.168.230.94 11.11.11.64
211.168.230.94 11.11.11.69
211.168.230.94 11.11.11.73
211.168.230.94 11.11.11.75
211.168.230.94 11.11.11.80
211.168.230.94 11.11.11.67
............. ..........
............. ..........
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.