Thanks for the response vgersh99 . Honestly, I am new to using unix. I tried some options with awk but the results are not matching with my requirement. Any help would be appreciated.
If this is homework then there is a seperate forum for this, if not then I would refer you back to the previous posts requesting what you've tried.
The forums here deliver help in many forms, however there is an expectation that the users will at least be prepared to share what they have already tried - other users in the main will respond with (in my experience) excellent feed back.
Everybody has to learn a bit at a time, throwing your toys out of the pram will achieve nothing - other than someone else having to pick your toys up for you!
Please do come back with at least the skeleton of what you have to give us a hint about your thought process.
We do want to help - regardless of how it looks on a surface...
This is a good exercise for Unix regex-es and can be solved by more than one approach.
Unfortunately, sudhakar1987 has posted his or her problem in another forum as well and received an - although unsatisfying so far - answer there. So I'm afraid we won't see his or her thought process resp. "solution by myself" in here.