extract number range from a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting extract number range from a file
# 1  
Old 06-03-2010
extract number range from a file

Hi Everyone,

a.txt
Code:
1272904667;1272904737;1
1272904747;1272904819;1
1272904810;1272904857;1
1272904889;1272904926;1
1272905399;1272905406;1
1272905411;1272905422;1

if i want to get the record, when the a.txt 1st field is between 1272904749 and 1272905399, any simple way by using awk, or perl?

Thanks
# 2  
Old 06-03-2010
Hi,

try with:

Code:
awk -F";" '{if ($1>1272904749 && $1<1272905399) print}' IN_FILE

This User Gave Thanks to albertogarcia For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

I need to find in a file a list of number where last two digit end in a range

I all I am tryng to find a way to sort a list of number in a file by the value of last two digit. i have a list like this 313202320388 333202171199 373202164587 393202143736 323202132208 353201918107 343201887399 363201810249 333201805043 353201791691 (7 Replies)
Discussion started by: rattoeur
7 Replies

2. Shell Programming and Scripting

Extract range from config file matching pattern

I have config file like this: server_name xx opt1 opt2 opt3 suboptions1 #suboptions - disabled suboptions2 pattern suboptions3 server_name yy opt1 opt2 opt3 suboptions1 pattern #suboptions - disabled suboptions2 So basically I want to extract the server... (1 Reply)
Discussion started by: nemesis911
1 Replies

3. Solaris

File System Error: BAD SUPERBLOCK AT BLOCK 16: NUMBER OF DIRECTORIES OUT OF RANGE

Hi All, we are having a file system error in one of our servers. The server failed to boot in usual user mode. Instead boot with single user mode and requesting to run a FSCK manually to repair the corrupted. see the below output. Netra T2000, No Keyboard Copyright 2008 Sun Microsystems,... (5 Replies)
Discussion started by: Buddhike G
5 Replies

4. Shell Programming and Scripting

Extract data from log file in specified range of time

I was searching for parsing a log file and found what I need in this link http://stackoverflow.com/questions/7575267/extract-data-from-log-file-in-specified-range-of-time But the most useful answer (posted by @Kent): # this variable you could customize, important is convert to seconds. # e.g... (2 Replies)
Discussion started by: kingk110
2 Replies

5. Shell Programming and Scripting

Perl extract number from file & write to file

I have 1 file that has elements as follows. Also the CVR(10) and the word "SAUCE" only appear once in the file so maybe a grep command would work? file1 CVR( 9) = 0.385E+05, ! VEHICLE CVR(10) = 0.246E+05, ! SAUCE CVR(11) = 0.162E+03, ! VEHICLE I need to extract the... (6 Replies)
Discussion started by: austinj
6 Replies

6. Shell Programming and Scripting

Extract a number from a line in a file and sed in another copied file

Dear all, I am trying to extract a number from a line in one file (task 1), duplicate another file (task 2) and replace all instances of the strings 300, in duplicated with the extracted number (task 3). Here is what I have tried so far: for ((k=1;k<4;k++)); do temp=`sed -n "${k}p"... (2 Replies)
Discussion started by: mnaqvi
2 Replies

7. Shell Programming and Scripting

extract a number within an xml file

Hi Everyone, I have an sh script that I am working on and I have run into a little snag that I am hoping someone here can assist me with. I am using wget to retrieve an xml file from thetvdb.com. This part works ok but what I need to be able to do is extract the series ID # from the xml and put... (10 Replies)
Discussion started by: tret
10 Replies

8. Shell Programming and Scripting

Cutting number from range in xml file

Hi folks, I need to find the following value: First,I need to find the starting section by finding the line: <process-type id="OC4J_RiGHTv_${SCHEMA_NAME}" module-id="OC4J"> Second,under this line I need to find the following line: <port id="rmi" range="3765-3776"/> And third,from this line... (4 Replies)
Discussion started by: nir_s
4 Replies

9. Shell Programming and Scripting

how to extract a range of lines from a file

I am reading a file that contains over 5000 lines and I want to assign it to a shell variable array (which has a restriction of 1024 rows). I had an idea that if I could grab 1000 record hunks of the file, and pipe the records out, that I could perform a loop until I got to the end and process 1000... (5 Replies)
Discussion started by: beilstwh
5 Replies

10. UNIX for Dummies Questions & Answers

Extract emp number from an error file.

I have to investigate error files created by SQL from an Oracle database. I would like to get just the emp number and pass this to another process, to out put specific details relating to that employee. Typical contents of an error file; STAFF_NUM TERM_DT DETAIL ------------ -----------... (2 Replies)
Discussion started by: jagannatha
2 Replies
Login or Register to Ask a Question