The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Quick question on grep: grabbing lines above and below thecoffeeguy Shell Programming and Scripting 3 05-29-2008 12:30 AM
Copy lines from a log file based on timestamp ranjiadmin UNIX for Advanced & Expert Users 1 05-22-2008 12:16 AM
Processing a log file based on date/time input and the date/time on the log file primp Shell Programming and Scripting 4 03-16-2008 08:23 AM
Picking the file based on Date..Requirement sureshg_sampat Shell Programming and Scripting 5 06-06-2007 02:51 AM
How can I get an if statement to execute based on number of lines in a file? LordJezo Shell Programming and Scripting 6 05-14-2004 07:50 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-13-2006
Registered User
 

Join Date: Jul 2006
Posts: 3
Grabbing lines out of a file based on a date

Hello,

I'm new to this forum and am not exactly sure where to post this question, so I'll start here. I'm looking for a command or simple script that will read in a large flat file (contains 2005 data) and will output a new file based on a quarter. Within each row, position 87-90 is a julian date with values 5001 thru 5365. If I want 4th quarter data, all rows with a date of 5274 thru 5365 should be written into a new file. What's the easiest way to accomplish this?

Thanks,
Brian
Reply With Quote
Forum Sponsor
  #2  
Old 07-13-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,297
Code:
awk '{
        qtr=substr($0,87,4);
        if(qtr > 5273 && qtr < 5366 ){ print $0 }
      }'  mylargefile  >  fourth_quarterfile
try something like that
Reply With Quote
  #3  
Old 07-17-2006
Registered User
 

Join Date: Jul 2006
Posts: 3
Thanks! It worked perfectly.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:28 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0