Home > OS >  Consult a shell script how to obtain documents conform to the conditions of certain line?
Consult a shell script how to obtain documents conform to the conditions of certain line?

Time:10-31

Seek expert advice,
Directory has more than one log file *. The log and log in every period of content, date of a line, a line description information, line type and operation results, similar to the below, now want to find out all the eligible type of operation and results, such as the Write file FAIL, then all the time and operation type results display a line, this should be how to Write, sed and AWK are not familiar, don't know which one should be used,

1900-0101 00:01:01
XXXXXX (description)
The INFO | Open file | AA. TXT | SUCCESS
1900-0101 00:01:02
XXXXXX (description)
The INFO | Write file | AA. TXT | FAIL

CodePudding user response:

Awk '/^ [0-9] {4} - [0-9] {4} [0-9] {2} : [0-9] {2} : [0-9] {2}/{a=$0; Next} {print $0? A "" $0: $0} 'a. og | grep" Write file "
A. og is to deal with the text file
  • Related