LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   reading a txt file (http://www.linuxquestions.org/questions/linux-software-2/reading-a-txt-file-457336/)

vidyashankara 06-22-2006 03:17 PM

reading a txt file
 
Lets say i have a text file named test.txt

It contains
ABC A 123
ABC A 456
ABC A 789
HET A 123
HET A 123
HET A 567
ABC A 123
ABC A 565
ABC A 123
TER
ABC B 123
ABC B 456
ABC B 789
HET B 123
HET B 123
HET B 567
ABC B 123
ABC B 565
ABC B 123
TER
HET 123
HET 123
HET 678

Is there a way for linux to print all the lines between ABC A and TER(Lines 1-10) on this case ?
The file is dynaminc, some files might have a 100 lines and some might have just 5. so head doesnt work. The problem is i dont know the lines where ABC A or TER exists. I am making a php script read the file with a system command. All i know is the first 5 characters which are "ABC A". Linuc should read the file when it reads this and stop reading when it hits the first TER after the ABC A

Any command to do this? Can you use head and tail with a string instead of a file name?

druuna 06-22-2006 04:19 PM

Hi,

Please don't ask the same question twice (also known as crossposting, which is against the rules).

Answer is in this thread.

jtshaw 06-22-2006 06:52 PM

Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.

http://www.linuxquestions.org/rules.php

Continue this here.


All times are GMT -5. The time now is 09:41 AM.