Grep the ip to a text file

Hi all,

We Have Squid server, We need to get the particular IP's log from /var/log/squid/access.log, if i need to get only the log's of 192.168.0.99, How can i get the log's to a separate file.

Here is the sample log what i have got from access.log file

1392706763.690    847 192.168.0.99 TCP_MISS/204 373 GET http://b.scorecardresearch.com/b? - DIRECT/125.56.200.163 -
1392706763.840    837 192.168.0.32 TCP_MISS/200 2518 GET http://engine.adzerk.net/ados? - DIRECT/54.225.174.133 application/javascript
1392706729.262      0 192.168.0.76 TCP_IMS_HIT/304 339 GET http://html5shim.googlecode.com/svn/trunk/html5.js - NONE/- text/javascript
1392706764.016      0 192.168.0.99 TCP_IMS_HIT/304 435 GET http://cdn-careers.sstatic.net/careers/gethired/sidebar.min.css? - NONE/- text/css
1392706713.330    250 192.168.0.115 TCP_MISS/204 524 GET http://s.youtube.com/stream_204? - DIRECT/74.125.236.194 text/html

There appear to be two IP addresses on many lines in this file. Am I correct in assuming that you only want to look for the IP address surrounded by spaces and not the ones following DIRECT/ ? If that is what you want try:

grep -F ' 192.168.0.99 ' access.log
1 Like

yes i want the local ip range which was start with 192.168.0. series , ok let me try and you will came to know about my result , thank you.

---------- Post updated 02-19-14 at 10:00 AM ---------- Previous update was 02-18-14 at 07:09 PM ----------

your Guide Work's Perfectly thanks sir, I used

grep -F '192.168.0.99' /var/log/squid/access.log >> /home/sysadmin/babinlonston/squid.txt