grep query to list 1 line [which is fixed] and the next line after it [variable text]
Hello,
How can I list the following with grep. I want to extract 2 lines fron a text file The fixed known part if it exists will static text and the text line after it will change. A sample file . . textline1 . . build: extracting built packages... somename-2.6.36.3-16.1.i586.rpm anothername2.6.36.3-16.1.i586.rpm . <eof> In the above case it would return build: extracting built packages... somename-2.6.36.3-16.1.i586.rpm If the fixed part does Not exist how can I return error code 1 Thanks Glenn |
what did your reading of the manpage indicate ?
|
grep -A1 "build: extracting built packages" foofile
Code:
-A NUM, --after-context=NUM |
Hi,
grep -A1 "build: extracting built packages..." infile Grep already tells you if the grep succeeded or not (echo $?) 0 - lines are found 1 - lines are not found 2 - an error occurred Hope this helps. |
All times are GMT -5. The time now is 04:12 PM. |