Parse a range of data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Parse a range of data
# 1  
Old 10-08-2008
Parse a range of data

Hello,

I have a file which has a range of date like:

00:00 test
00:01 test2
00:02 test3
00:03 test4
00:04 test5
00:05 test6

Using input (stdin) i would like to parse the data 00:01 to 00:04. The output file should be like this:

00:01 test2
00:02 test3
00:03 test4
00:04 test5

How i do that? Many thanks in advance!
Ricardo Santos
# 2  
Old 10-08-2008
Code:
<sourcescript>| sed -n '/^00.01/,/^00.04/p'
# or
sed -n '/^00.01/,/^00.04/p' <sourcefile>

# 3  
Old 10-08-2008
Quote:
Originally Posted by jim mcnamara
Code:
<sourcescript>| sed -n '/^00.01/,/^00.04/p'
# or
sed -n '/^00.01/,/^00.04/p' <sourcefile>

Thank you very much it works like a charm!

Best Regards,
Ricardo Santos
# 4  
Old 10-08-2008
It might work try this:

read input1
read input2
awk '/$input1/, /$input2/' source_file
# 5  
Old 10-08-2008
Hammer & Screwdriver here is one approach

Code:
> cat file1
00:00 test
00:01 test2
00:02 test3
00:03 test4
00:04 test5
00:05 test6
> grep "^00:0[0-4]" file1
00:00 test
00:01 test2
00:02 test3
00:03 test4
00:04 test5

# 6  
Old 10-08-2008
Quote:
Originally Posted by dddkiran
It might work try this:

read input1
read input2
awk '/$input1/, /$input2/' source_file
yeah thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with sum range of data set together

Input File: 2000 3 1998 2 1997 2 1994 1 1991 1 1989 1 1987 2 1986 2 1985 1 1984 1 . . 10 277256 9 278274 8 282507 7 284837 6 287066 5 292967 (4 Replies)
Discussion started by: perl_beginner
4 Replies

2. Shell Programming and Scripting

Filtering data base on range

Hi All, I have the file in following format. I need to change column 16 and column 17 for those lines which has atleast one numerical digit in column 2 , with the exception on SUPP1 Input file : S00005615|1044|0|0.00|0|0.00| |112|-30|28.1|0|0| |20130331|220.2|2|3|... (2 Replies)
Discussion started by: nua7
2 Replies

3. Shell Programming and Scripting

Display data from a range of dates

I have a data in a file called SCHED which has 5 columns: sched no, date, time, place and remarks. The image is shown below. http://dl.dropbox.com/u/54949888/Screenshot%20from%202013-01-02%2002%3A42%3A25.png Now, I want to display only the schedules which fall under a certain date range which... (2 Replies)
Discussion started by: angilulu
2 Replies

4. Shell Programming and Scripting

Parse data

Guys , please help me out with another AWK solution ... Input Device Physical Name : Not Visible Device Symmetrix Name : 0743 Front Director Paths (2): { ---------------------------------------------------------------------- ... (5 Replies)
Discussion started by: greycells
5 Replies

5. UNIX for Dummies Questions & Answers

Fitting a range of data

Hi, I am able to write an awk program that fits using the chi squared minimization method for each number is a data column... but I am wondering if it is possible to do that for a range of numbers at the same time. If I have a column for the observed data... and then say 10 columns for... (13 Replies)
Discussion started by: cosmologist
13 Replies

6. 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

7. Shell Programming and Scripting

Parse data

hi i have a file p1.htm <div class="colorID2"> aaaa aaaa aa <br/> bbbbbbbb bbb<br/> <br/>cccc ccc ccc </div><div class="colorID1"> dddd d ddddd<br/> eeee eeee eeeeeeeeee<br/> fffff <br/>g gg<br/> (5 Replies)
Discussion started by: saw7
5 Replies

8. Shell Programming and Scripting

How to parse data?

Hi all, I have output of paction command looking like this: RELCI 0 IP address 1.2.16.3 Xmit: CURRENT Recv: WAIT_HEADER 0 congestions 2617/0 buf. sent/rec Xmit: CURRENT Recv: WAIT_HEADER 0 congestions 0/0 buf. sent/rec BUFFER Xmit: ... (6 Replies)
Discussion started by: sameucho
6 Replies

9. Shell Programming and Scripting

Range of data from a log file .

I am having a log file in which i need a range of data from specific date range. $cat my.log Jan 07 15:39:03 N/A _M_LocalDirectory listFiles(): listing files from dir Jan 07 15:39:03 N/A _w_fm_log:_f_Push() _w_fm_log_export_ftppush(): Files f Jan 07 05:58:35 N/A _w_fm_log_autoexport ... (6 Replies)
Discussion started by: posix
6 Replies

10. Programming

How to parse IP range in CIDR format in C

Hello everybody, I'm coding a network program and i need it to "understand" ip ranges, but i don't know how to make to parse an IP CIDR range, let's say "172.16.10.0/24" to work with the specified IP range. I've found a program which does it, but i don't understand the code. Here is the... (3 Replies)
Discussion started by: semash!
3 Replies
Login or Register to Ask a Question