Home > OS >  For help, how to display a file specified two lines
For help, how to display a file specified two lines

Time:11-03

A log file as follows, I need to read the file, and output the result: usr1 command: AAA results success

Results: the success,
XXXX (description)
User: usr1 execute the command: AAA

Results: failure,
XXXX (description)
User: usr1 execute the command: BBB

Can now through the grep to users: usr1 execute command: "AAA", how can I get two rows on the results, and the need of field Mosaic line?
Use sed - n '3 p; After 1 p 'output is as a result, the first user, how is it possible to invert? thank you

CodePudding user response:

Awk '/execution result/{a=$0; Next} {print $0? $0 "" a: $0} 'a. og | grep" users "| sed' s/users://. S/execute commands:/command:/. S/execution results:/results/'

This problem like before, you have the time can study the awk the use of this tool
  • Related