0

In file 1,
'Server restoration is complete now. It will be operational within few seconds. Please keep all the log file once the restoration is complete.'

In file 2,
'Restoration was successfully terminated due to .SA file mismatch. Please keep the log file for your future reference.'

Now I want to get both the complete lines from my file 1 and file 2. How can I print or get these lines at a time?

  • if you only want both files , cat file1 file2 but it's very ugly... – demonking Aug 10 '15 at 15:56
  • yes.... from those files I just want to extract those two lines. @demonking – pmaipmui Aug 10 '15 at 16:06
2

I hope i understand it right.

cat file1 file2 | grep -E '(^Restoration\ was\ successfully|^Server\ restoration\ is\ complete)'

When the files start with single-quotes :

cat file1 file2 | grep -E '(^\'Restoration\ was\ successfully|^\'Server\ restoration\ is\ complete)'
  • 1
    UUOC: You can avoid cat with grep -hE '(...)' file1 file2 – Walter A Aug 10 '15 at 21:00
  • Yes.... its working now.... :-) @demonking – pmaipmui Aug 11 '15 at 2:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.