How to extract certain part of log file?

Hi there,

I'm having some problem with UNIX scripting (ksh), perhaps somebody can help me out?

For example:
------------
Sample content of my log file (text file):
--------------------------------------
File1: ....
info_1 ...
info_2 ...
info_3 ...

File2: ....
info_1 ...
info_2 ...
info_3 ...

File3: ....
info_1 ...
info_2 ...
info_3 ...

...Etc

I'm having a problem to extract relevant information from a portion part of the log file. For example, how can I extract all relevant information for "File2" only (including info_1, info_2 and info_3)?

So if the desired output should be:
---------------------------------
File2: ....
info_1 ...
info_2 ...
info_3 ...

My scripting skill still not very advance. so any help or suggestion would be much appreciated.

Thanks.

</> cat "your log.file" | sed -n '/^File2/,/^File3/p' | sed '$d'
awk 'BEGIN{RS=""} /File2/' file

Hi All,

Thanks a lot for your response. Appreciate it.

But given another situation such as below, is it possible to extract portion of information based on key word: PROBLEM001, providing this is a unique key word. Or can I use the same method mentioned earlier? Please advice. Thanks.

File1: ....
info_1 ...
info_2 ...
info_3 ...

File2: ....
info_1 ... PROBLEM001
info_2 ...
info_3 ...

File3: ....
info_1 ...
info_2 ...
info_3 ...

File4: ....
info_1 ... PROBLEM001
info_2 ...
info_3 ...

...
...
Etc

OUTPUT:
--------
File2: ....
info_1 ... PROBLEM001
info_2 ...
info_3 ...

File4: ....
info_1 ... PROBLEM001
info_2 ...
info_3 ...

PLz assist guys n gals... i wanna post a thread but dont kno exactly ho to do it... have some doubts regarding unix.

Yes, same thing. You insert the key word between /keyWord/

awk 'BEGIN{RS="";ORS="\n\n"} /PROBLEM001/' file

removing my quote because Ripat had already answered

hey plz reply to my earlier post... How do i post a new thread?

Go to 'form view' nad there left on the top you'll see a button "New Thread"

Hi ripat,

Thanks for your prompt response.

But what does this code mean?
awk 'BEGIN{RS="";ORS="\n\n"} ...

Thanks.

This is the point you go to the man page for awk and look at how RS and ORS are used.