![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
awk '{
qtr=substr($0,87,4);
if(qtr > 5273 && qtr < 5366 ){ print $0 }
}' mylargefile > fourth_quarterfile
|
|
#3
|
|||
|
|||
|
Thanks! It worked perfectly.
|
|||
| Google The UNIX and Linux Forums |