Sponsored Content
Top Forums Shell Programming and Scripting Need to filter data based on sysdate Post 302926650 by Don Cragun on Tuesday 25th of November 2014 04:14:15 PM
Old 11-25-2014
Quote:
Originally Posted by Akshay Hegde
Try

Code:
$ awk  -F, '{c=$16; gsub(/[: ]/,"",c)} c > sys' sys="$(date +'%Y%m%d%H%M%S')" infile

Code:
$ awk -F, 'BEGIN{sys = strftime("%Y%m%d%H%M%S")}{c=$16; gsub(/[: ]/,"",c)} c > sys'  infile

Since the date data in the file is in the correct order (most significant data comes first in the string) and the fields (year, month, day, hour, minute, and second) are all fixed length fields, the gsub()calls can be avoided if the system date is formatted the same way the dates are formatted in the file:
Code:
awk -F, '$16 > sys' sys="$(date +'%Y%m%d %H:%M:%S')" infile

or, if the GNU time extensions are in your version of awk,
Code:
awk -F, 'BEGIN{sys = strftime("%Y%m%d %H:%M:%S")} $16 > sys' infile

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

filter based on column value

I have a file with colon separated values.. the sample is attached below. No of fields in each record/line is dependent on the value of field53. What I need to do is to design a special filter based on specific requirement of some match of values in particular column or combination of columns. ... (2 Replies)
Discussion started by: rraajjiibb
2 Replies

2. Shell Programming and Scripting

extract data from a data matrix with filter criteria

Here is what old matrix look like, IDs X1 X2 Y1 Y2 10914061 -0.364613333 -0.362922333 0.001691 -0.450094667 10855062 0.845956333 0.860396667 0.014440333 1.483899333... (7 Replies)
Discussion started by: ssshen
7 Replies

3. Shell Programming and Scripting

copy lines from log files based on timestamp and sysdate

I am sorry to repost this question. it was not clear, and I had the meeting and didn't response the question on time. I do really need help and appreciate your help very much. I'm looking for a simple shell script that will read lots of audit log file (*.aud) in a log fold every 10 minutes,... (1 Reply)
Discussion started by: percvs88
1 Replies

4. Shell Programming and Scripting

copy lines from log files based on timestamp and sysdate

I'm looking for a command or simple script that will read lots of audit log file (*.aud) in log fold every 10 minutes, and will output to one file based on sysdate - 10 minutes. assume the script is run at 11:12:20, and it should grep the line from Wed Jun 17 11:02:43 2009 to end of file. after... (4 Replies)
Discussion started by: percvs88
4 Replies

5. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

6. Linux

filter data

hi all, here is my question. i have the following data Block 1 a b c d e f g h i Block 2 j k l m n o p q r i need to grep all information from block 1 i.e 'a to i' (6 Replies)
Discussion started by: yprudent
6 Replies

7. Shell Programming and Scripting

awk filter based on column value (variable value)

Hi, I have a requirement to display/write the 3rd column from a file based on the value in the column 3. Ex: Data in the File (comma delimited) ID,Value,Description 1,A,Active 1,I,Inactive 2,S,Started 1,N,None 2,C,Completed 2,F,Failed I need to first get a list of all Unique IDs in... (7 Replies)
Discussion started by: kiranredz
7 Replies

8. Shell Programming and Scripting

Filter records based on 2nd file

Hello, I want to filter records of a file if they fall in range associated with a second file. First the chr number (2nd col of 1st file and 1st col of 2nd file) needs to be matched. Then if the 3rd col of the first file falls within any of the ranges specified by the 2nd and 3rd cols , then... (4 Replies)
Discussion started by: ritakadm
4 Replies

9. Shell Programming and Scripting

Filter Data based on codes

Hello, I have a question on how to filter the data on multiple columns. The problem is I have one table with 25 columns, 4500 rows. I need to filter out the data based on some codes like 'XXXX', I have 25 codes to check on that table. My requirement is that which ever row has this code I... (1 Reply)
Discussion started by: sandeep309
1 Replies

10. Shell Programming and Scripting

Filter tab file based on column value

Hello I have a tab text file with many columns and have to filter rows ONLY if column 22 has the value of '0', '1', '2' or '3' (out of 0-5). If Column 22 has value '0','1', '2' or '3' (highlighted below), then remove anything less than 10 and greater 100 (based on column 5) AND remove anything... (1 Reply)
Discussion started by: nans
1 Replies
HTTP::Proxy::BodyFilter::lines(3pm)			User Contributed Perl Documentation		       HTTP::Proxy::BodyFilter::lines(3pm)

NAME
HTTP::Proxy::BodyFilter::lines - A filter that outputs only complete lines SYNOPSIS
use HTTP::Proxy::BodyFilter::lines; use MyFilter; # this filter only works on complete lines my $filter = MyFilter->new(); # stack both filters so that they'll handle text/* responses $proxy->push_filter( mime => 'text/*', response => HTTP::Proxy::BodyFilter::lines->new, response => $filter ); # I want my lines to end with '!' # This is equivalent to $/ = '!' in a normal Perl program my $lines = HTTP::Proxy::BodyFilter::lines->new('!'); DESCRIPTION
The HTTP::Proxy::BodyFilter::lines filter makes sure that the next filter in the filter chain will only receive complete lines. The "chunks" of data received by the following filters with either end with " " or will be the last piece of data for the current HTTP message body. You can change the idea the filter has of what is a line by passing to its constructor the string it should understand as line ending. " " is the default value. my $filter = HTTP::Proxy::BodyFilter::lines->new( $sep ); This is similar to modifying $/ in a Perl program. In fact, this filter has a behaviour so similar to modifying $/ that it also knows about "paragraph mode" and "record mode". Note that the "slurp" mode is not supported. Please use HTTP::Proxy::BodyFilter::complete to enable the generic store and forward filter mechanism. METHODS
This filter defines the following methods, which are automatically called: init() Initialise the filter with the EOL information. filter() Keeps unfinished lines for later. will_modify() This method returns a false value, thus indicating to the system that it will not modify data passing through. SEE ALSO
HTTP::Proxy, HTTP::Proxy::BodyFilter. AUTHOR
Philippe "BooK" Bruhat, <book@cpan.org>. COPYRIGHT
Copyright 2003-2006, Philippe Bruhat. LICENSE
This module is free software; you can redistribute it or modify it under the same terms as Perl itself. perl v5.12.4 2011-07-03 HTTP::Proxy::BodyFilter::lines(3pm)
All times are GMT -4. The time now is 11:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy