grepping for numbers in between


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers grepping for numbers in between
# 1  
Old 11-12-2004
grepping for numbers in between

Ok here's the situation I have a log like the following:

(S0) Time: 124937.326033 - SendingTime: '20041108-12:49:29'
(S0) Time: 124937.389946 - SendingTime: '20041108-12:49:29'
(S0) Time: 124937.462494 - SendingTime: '20041108-12:49:29'
(S0) Time: 124937.551056 - SendingTime: '20041108-12:49:29'
(S0) Time: 124937.617128 - SendingTime: '20041108-12:49:29'
(S0) Time: 124937.689085 - SendingTime: '20041108-12:49:29'


I can have a few thousand lines like this in a log. How can I grep according to the time using the the numbers after "Time:" or after the date. Like if I want to grep out everything between 10:30 to 1:30

Any info you can spare would be much appreciated ..

thanks in advance
# 2  
Old 11-12-2004
Try the following ... pass lowervalue and upper value as command line args.

script 12 14 will give times between 12:30 and 14:30
file1 is the file having data.

code:
-----------------------------------------

lowerlimit=$13000
upperlimit=$23000

while read line
do
patt=`echo $line | cut -d" " -f 3 | cut -d"\." -f 1`


if test $patt -ge $lowerlimit -a $patt -le $upperlimit
then
echo $line ;
fi

done < file1


---------------------------------------------------- ----
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Decimal numbers and letters in the same collums: round numbers

Hi! I found and then adapt the code for my pipeline... awk -F"," -vOFS="," '{printf "%0.2f %0.f\n",$2,$4}' xxx > yyy I add -F"," -vOFS="," (for input and output as csv file) and I change the columns and the number of decimal... It works but I have also some problems... here my columns ... (7 Replies)
Discussion started by: echo manolis
7 Replies

2. UNIX for Dummies Questions & Answers

Print numbers and associated text belonging to an interval of numbers

##### (0 Replies)
Discussion started by: lucasvs
0 Replies

3. Shell Programming and Scripting

the smallest number from 90% of highest numbers from all numbers in file

Hello All, I am having problem to find what is the smallest number from 90% of highest numbers from all numbers in file. I am having file with thousands of lines and hundreds of columns. I am familiar mainly with bash but I am open to whatever suggestion witch will lead to the solutions. If I... (11 Replies)
Discussion started by: Apfik
11 Replies

4. UNIX for Dummies Questions & Answers

Replace US numbers with European numbers

hey, I have a file with numbers in US notation (1,000,000.00) as well as european notation (1.000.000,00) i want all the numbers to be in european notation. the numbers are in a text file, so to prevent that the regex also changes the commas in a sentence/text i thought of: sed 's/,/\./'... (2 Replies)
Discussion started by: FOBoy
2 Replies

5. Shell Programming and Scripting

Grepping text by providing line numbers.

Dear Friends, I have a flat file from which I want to grep line no. 7,10, 19 to 35, 37. How can it be done? Thank you in advance Anushree (6 Replies)
Discussion started by: anushree.a
6 Replies

6. Shell Programming and Scripting

read numbers from file and output which numbers belongs to which range

Howdy experts, We have some ranges of number which belongs to particual group as below. GroupNo StartRange EndRange Group0125 935300 935399 Group2006 935400 935476 937430 937459 Group0324 935477 935549 ... (6 Replies)
Discussion started by: thepurple
6 Replies

7. UNIX for Dummies Questions & Answers

seperating records with numbers from a set of numbers

I have two files one (numbers file)contains the numbers(approximately 30000) and the other file(record file) contains the records(approximately 40000)which may or may not contain the numbers from that file. I want to seperate the records which has the field 1=(any of the number from numbers... (15 Replies)
Discussion started by: Shiv@jad
15 Replies

8. Shell Programming and Scripting

Please help on grepping

Hi All, I have a log file and I want to parse the logfile with a script.A sample text is shown below: I would grep on "return code " on this file. Any idea how the lines above and below the grep patterns could also be extracted. Thanks! nua7 The runLoggingInstall return code is 0... (3 Replies)
Discussion started by: nua7
3 Replies

9. Shell Programming and Scripting

grepping around

Using shell scripts, I use grep to find the word “error” in a log file: grep error this.log. How can I print or get the line 3 lines below the line that word “error” is located? Thanks in advance for your response. (9 Replies)
Discussion started by: cbeauty
9 Replies

10. UNIX for Dummies Questions & Answers

grepping

Is there a way to grep for something and then print out 10 lines after it. for example if I want to grep for a word, then output the following 10 or whatever number of lines after the word. (5 Replies)
Discussion started by: eloquent99
5 Replies
Login or Register to Ask a Question