regex - manipulating space delimited text file -


i have text file in following format

4 test file 4500 5 test 6000 6 not sure how work 9000  want extract data follows  field1 = 4 field2 = test file field3 = 4500 

this first row, want rows in format. can please help? either sed or awk no perl. prefer sed and/or awk.

i'm having issues field2 (which either single word or multiple words string) enclose single or double quotes. rest guess easy. please help

using sed...

sed -re 's/(\s+)\s+(.*)\s+(\s+)/field1 = \1\nfield2 = \2\nfield3 = \3/g' file 

output:

field1 = 4 field2 = test file field3 = 4500 field1 = 5 field2 = test field3 = 6000 field1 = 6 field2 = not sure how work field3 = 9000 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -