Grabbing lines out of a file based on a date

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grabbing lines out of a file based on a date
# 1  
Old 07-13-2006
Grabbing lines out of a file based on a date


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?

# 2  
Old 07-13-2006
awk '{
        if(qtr > 5273 && qtr < 5366 ){ print $0 }
      }'  mylargefile  >  fourth_quarterfile

try something like that
# 3  
Old 07-17-2006
Thanks! It worked perfectly.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grabbing text between two lines with shell variables.

I would like to grab complex html text between lines using variables. I am running Debian and using mksh shell. Here is the part of the html that I want to extract from. I would like to extract the words 'to love,' and I would like to use the above and below lines as reference points. ... (3 Replies)
Discussion started by: bedtime
3 Replies

2. Post Here to Contact Site Administrators and Moderators

Read file name based on date

Hi, I have file name as Example extract_ces_v3_p044444rlt_20160514045705.txt.pgp extract_ces_v3_p044444rlt_20160614049705.txt.pgp extract_ces_v3_p044444rlt_20160714046705.txt.pgp I have to read file name based on date(i.e) files with same date and copy to another directory in shell script.... (3 Replies)
Discussion started by: caba_jones
3 Replies

3. HP-UX

HP/UX command to pull file name/date based on date

HI, Can anyone tell me how to pull the date and file name separated by a space using the find command or any other command. I want to look through several directories and based on a date timeframe (find -mtime -7), output the file name (without the path) and the date(in format mmddyyyy) to a... (2 Replies)
Discussion started by: lnemitz
2 Replies

4. Shell Programming and Scripting

Script to determine Date,TotalFile,total size of file based on date

I have file listed like below -rw-r--r--+ 1 test test 17M Nov 26 14:43 test1.gz -rw-r--r--+ 1 test test 0 Nov 26 14:44 test2.gz -rw-r--r--+ 1 test test 0 Nov 27 10:41 test3.gz -rw-r--r--+ 1 test test 244K Nov 27 10:41 test4.gz -rw-r--r--+ 1 test test 17M Nov 27 10:41 test5.gz I... (5 Replies)
Discussion started by: krish2014
5 Replies

5. Shell Programming and Scripting

Extracting specific lines of data from a file and related lines of data based on a grep value range?

Hi, I have one file, say file 1, that has data like below where 19900107 is the date, 19900107 12 144 129 0.7380047 19900108 12 168 129 0.3149017 19900109 12 192 129 3.2766666E-02 ... (3 Replies)
Discussion started by: Wynner
3 Replies

6. UNIX for Dummies Questions & Answers

Truncating file based on date

Hi, I need to truncate a file based on date.Suppose i have a log file which is getting updated every date,i need to keep 7 days worth of data(like sysdate-7) and rest i want to truncate it.Can some help me? (5 Replies)
Discussion started by: Param0073
5 Replies

7. UNIX for Dummies Questions & Answers

Delete lines with duplicate strings based on date

Hey all, a relative bash/script newbie trying solve a problem. I've got a text file with lots of lines that I've been able to clean up and format with awk/sed/cut, but now I'd like to remove the lines with duplicate usernames based on time stamp. Here's what the data looks like 2007-11-03... (3 Replies)
Discussion started by: mattv
3 Replies

8. Shell Programming and Scripting

Split the file based on date value

Hi frnds, I have flat file as . Say : output-file1.txt Output-file2.txt (1 Reply)
Discussion started by: Gopal_Engg
1 Replies

9. Shell Programming and Scripting

Grabbing lines from one file based on another file

Hi everyone, I have a file that contains multiple columns. Basically the identifiers are on column 1. Here is an example: target1 6.7 8.4 target2 5.3 2.3 target3 4.3 2.3My goal is to pull out certain identifiers from column 1 (pull the entire row) and put it into another file. The... (4 Replies)
Discussion started by: gisele_l
4 Replies

10. Shell Programming and Scripting

Quick question on grep: grabbing lines above and below

Just a quick question on grep/egrep. I am writing a shell script that is looking for certain strings in a text file. It works well and gets exactly what I need. However, the way the program writes to the text file, it puts the timestamp in a line above the string I am looking for and the path... (3 Replies)
Discussion started by: thecoffeeguy
3 Replies
Login or Register to Ask a Question

Featured Tech Videos