grep - How to extract multiple line strings between two keywords using grepwin -


hi have directory of files , each file has multiple languages text strings on multiple lines. using grepwin extract english text strings , save text file. typically in each file english text inside switch/case condition this:

default //english     bitmap 8 20 "bmp5/warning.bmp"     ltext 5 1 11 "usb device overload"           ltext 85 20 13 "usb"     ltext 50 33 13 "device overload!" break  case _french             bitmap 8 20 "bmp5/warning.bmp"             ltext 5 1 11 "surcharge clé usb!"              ltext 45 30 13 "surcharge clé usb"  break  

since english text between 'default' , 'break' want use 2 keywords delimeter. text between 2 keywords needs saved out text file.

can @ all.

thanks guys

through grep.

$ grep -opz '(?s)(?<=\n|^)default\b[^\n]*\n\k.*?(?=\nbreak\b)' file     bitmap 8 20 "bmp5/warning.bmp"     ltext 5 1 11 "usb device overload"           ltext 85 20 13 "usb"     ltext 50 33 13 "device overload!" 

to save result file, need use output redirection operator.

grep -opz '(?s)(?<=\n|^)default\b[^\n]*\n\k.*?(?=\nbreak\b)' infile > outfile 

from man grep

  -p, --perl-regexp         pattern perl regular expression   -z, --null-data           data line ends in 0 byte, not newline 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -