Seeking for your assistance on how to get the two pattern below.
Example
file1.txt
GET /Sun/Cellular/version1/12
HTTP/1.0 100 Internal Error
GET /Sun/Cellular/version1
GET /Sun/Cellular/version1
GET /Sun/Cellular/version1
GET /Sun/Cellular/version1/13
HTTP/1.0 100 Internal Error
GET /Sun/Cellular/version1
GET /Sun/Cellular/version1
Expected Output
GET /Sun/Cellular/version1/12
HTTP/1.0 100 Internal Error
GET /Sun/Cellular/version1/13
HTTP/1.0 100 Internal Error
I tried using egrep but it will print all "GET /Sun/Cellular/version1/". what i want is to print records with "HTTP/1.0 100 Internal Error"(please see expected output)
Not working sir sea. it's prints all the GET /Sun/Cellular/version1/. what i want is to display the GET /Sun/Cellular/version1/12 and HTTP/1.0 100 Internal Error
what i mean is if the record has "HTTP/1.0 100 Internal Error" it will print the GET /Sun/Cellular/version1/* and "HTTP/1.0 100 Internal Error" Please see below sample output
Sample File
GET /Sun/Cellular/version1/12
HTTP/1.0 100 Internal Error
GET /Sun/Cellular/version1
GET /Sun/Cellular/version1
GET /Sun/Cellular/version1
GET /Sun/Cellular/version1/13
HTTP/1.0 100 Internal Error
GET /Sun/Cellular/version1
GET /Sun/Cellular/version1
Expected Output
GET /Sun/Cellular/version1/12
HTTP/1.0 100 Internal Error
GET /Sun/Cellular/version1/13
HTTP/1.0 100 Internal Error
Wow thank you very much Sir RavinderSingh13 and RudiC it works now.. wew at last... thank you very much all for your support. i think i need to learn more from you guys xD thank u thank u...
Please be aware that - due to your somewhat unspecific specification - the two proposals are NOT equivalent. RavinderSingh's looks for "...version1/something" and prints two lines from there, no matter if an error exists. Which is fine and fulfills the spec. Mine looks for "Error" and prints this along with the line before it, no matter what the version is.
So - in future specs you should be way clearer about what you really need!