Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract all lines between two user-defined values, inclusive 1

Status
Not open for further replies.

ericpatton

Technical User
Mar 4, 2006
6
CA
I have a text file consisting of 3 columns: time, latitude, and longitude. My bash script prompts the user for a beginning time and an end time, and I want to use awk to extract all values bewteen these two, including the user-defined values, to a new text file. Each subsequent start-end pair will again use awk and append the selection to the same newly-created text file.

Thanks,

~ Eric.
 
And what is your problem ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
My problem is I'm not sure how to extract all records between and including these two values.

~ Eric.
 
What have you tried so far and what is not working ?
A starting point:[tt]
start="foo"
end="bar"
awk '$1>="'$start'" && $1<="'$end'"' /path/to/input > output[/tt]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I was just completely stuck - but I think this will work perfectly, thank you!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top