0

I am trying to retrieve value between two strings which are present multiple time in one single line.

here is what I got:

time="1441491171" <DISP>something</DISP><DISP>stuff</DISP><DISP>possible</DISP>

the order for these strings as it might change by having additional strings...

I am trying to get these values are below:

"1441491171" something stuff possible

Many thanks for you help, AL.

user2335924
  • 57
  • 1
  • 9

2 Answers2

2

You can use the following sed command:

sed 's/time=//;s/<\/*DISP>/ /g'

These are two commands, separated by a semicolon:

  • s/time=// removes the time= prefix
  • s/<\/*DISP>/ /g removes the <DISP> or </DISP> tags by a space
hek2mgl
  • 152,036
  • 28
  • 249
  • 266
0

A different aproach selecting matches instead of deleting not wanted strings:

$ grep -oP 'time=\K"\d+"|(?<=DISP>)\w+(?=</DISP)' file
"1441491171" 
something
stuff
possible

$ grep -oP 'time=\K"\d+"|(?<=DISP>)\w+(?=</DISP)' file |tr  '\n' ' '
"1441491171"  something stuff possible
Juan Diego Godoy Robles
  • 14,447
  • 2
  • 38
  • 52