The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 03:30 AM
Copy lines from a log file based on timestamp ranjiadmin UNIX for Advanced & Expert Users 1 05-22-2008 03: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 11:23 AM
Picking the file based on Date..Requirement sureshg_sampat Shell Programming and Scripting 5 06-06-2007 05: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 10:50 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-13-2006
bsp18974 bsp18974 is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 4
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
  #2 (permalink)  
Old 07-13-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

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

Join Date: Jul 2006
Posts: 4
Thanks! It worked perfectly.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:47 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0