Solved

awk delete lines

Posted on 2013-12-22
2
438 Views
Last Modified: 2013-12-22
how should i delete lines older then 5 minute from a file which has lines as below


   2013-12-22 22:40:44.413        37.123.97.70    95.88.68.72     14109   49304   385     0x18    6       256
         2013-12-22 22:40:44.414        37.123.99.218   88.252.179.218  31701   4621    68      0x10    6       256
         2013-12-22 22:40:44.414        178.20.231.102  78.183.53.41    80      53905   1514    0x10    6       256
         2013-12-22 22:40:44.415        185.9.159.17    139.27.241.27   4980    445     70      0x02    6       256
         2013-12-22 22:40:44.415        178.20.225.205  173.245.53.168  80      58023   82      0x12    6       256
         2013-12-22 22:40:44.415        178.20.230.21   78.166.207.202  7777    55093   103     0x12    17      256
         2013-12-22 22:40:44.416        178.20.231.102  94.123.206.219  80      15558   1462    0x10    6       256
         2013-12-22 22:40:44.560        178.20.231.102  78.183.53.41    80      53916   1514    0x10    6       256
         2013-12-22 22:40:44.561        185.9.159.61    50.23.124.46    2794    3389    68      0x14    6       256
         2013-12-22 22:40:44.561        178.20.230.190  60.173.11.197   80      52219   1522    0x10    6       256
         2013-12-22 22:40:44.562        185.9.159.61    50.23.172.118   2779    3389    68      0x04    6       256
         2013-12-22 22:40:44.562        185.9.156.136   88.170.121.30   7102    57235   1428    0x18    6       256
         2013-12-22 22:40:44.562        178.20.230.198  88.244.251.111  27015   27005   125     0x18    17      256
         2013-12-22 22:40:44.562        178.20.227.86   173.194.70.116  3396    443     91      0x18    6       256
         2013-12-22 22:40:44.683        178.20.228.120  94.121.72.60    28281   56120   122     0x18    6       256
         2013-12-22 22:40:44.684        178.20.230.198  95.15.92.219    27015   27005   147     0x18    17      256
         2013-12-22 22:40:44.684        178.20.225.204  141.101.98.94   80      15427   74      0x10    6       256
         2013-12-22 22:40:44.684        178.20.230.21   88.246.211.15   7777    15911   330     0x10    17      256
         2013-12-22 22:40:44.685        185.9.159.61    50.23.150.170   4022    3389    349     0x18    6       256
         2013-12-22 22:40:44.705        178.20.227.71   71.122.225.92   4022    3389    1522    0x18    17      256
         2013-12-22 22:40:44.705        185.9.159.218   193.140.225.132 80      31266   1522    0x10    6       256
         2013-12-22 22:40:44.754        178.20.231.4    78.177.107.74   80      22942   1462    0x10    6       256
         2013-12-22 22:40:44.755        185.9.159.160   164.29.48.61    3708    445     70      0x02    6       256
         2013-12-22 22:40:44.755        37.123.100.41   188.3.4.237     13200   1830    182     0x18    6       256
         2013-12-22 22:40:44.756        185.9.156.136   88.231.184.107  9999    1296    68      0x10    6       256
         2013-12-22 22:40:44.756        185.9.159.158   78.177.74.180   27015   27005   89      0x10    17      256
         2013-12-22 22:40:44.756        185.9.159.61    50.23.196.186   3044    3389    68      0x10    6       256
         2013-12-22 22:40:44.756        185.9.159.70    62.165.213.180  10334   33982   76      0x10    17      256
         2013-12-22 22:40:44.757        178.20.231.92   195.175.39.91   53      43945   96      0x10    17      256
         2013-12-22 22:40:44.861        37.123.99.213   62.210.129.52   2576    80      68      0x10    6       256
         2013-12-22 22:40:44.861        37.123.99.196   88.232.195.163  31691   55976   110     0x18    6       256
         2013-12-22 22:40:44.862        185.9.159.61    50.23.38.98     4675    3389    93      0x18    6       256
         2013-12-22 22:40:44.863        178.20.227.71   199.223.219.71  4675    3389    1522    0x18    17      256
         2013-12-22 22:40:44.863        185.9.159.61    50.23.184.102   3363    3389    68      0x10    6       256
         2013-12-22 22:40:44.864        185.9.159.61    50.23.33.215    3842    3389    68      0x10    6       256
         2013-12-22 22:40:44.864        178.20.230.180  78.179.132.228  9998    49465   1514    0x10    6       256
         2013-12-22 22:40:44.865        178.20.226.121  176.227.204.58  52919   80      74      0x10    6       256
         2013-12-22 22:40:45.053        185.9.159.61    50.23.113.165   3927    3389    115     0x18    6       256
         2013-12-22 22:40:45.053        178.20.231.82   78.168.36.236   80      63232   1474    0x10    6       256
         2013-12-22 22:40:45.053        178.20.231.95   217.79.181.38   80      56874   1522    0x10    6       256
         2013-12-22 22:40:45.054        185.9.159.61    50.20.217.230   1192    3389    449     0x18    6       256
         2013-12-22 22:40:45.054        185.9.159.61    50.23.196.26    4276    3389    68      0x10    6       256
         2013-12-22 22:40:45.055        178.20.225.197  141.101.92.234  80      50112   1522    0x10    6       256

Open in new window

0
Comment
Question by:3XLcom
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
Comment Utility
perl -MPOSIX -i.bak -ane 'BEGIN{$d=strftime"%Y-%m-%d %H:%M:%S",localtime time-300}print if "@F[0,1]" ge $d'  file
0
 

Author Closing Comment

by:3XLcom
Comment Utility
thank you
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
LINUX ZIP - UNCOMPRESS WINDOWS PATH 3 55
unix example issues 18 44
LINUX CENTOS + APACHE 9 31
Codiing Non-Existent Links 4 22
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Utilizing an array to gracefully append to a list of EmailAddresses
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now