I use a command to find strings and numbers in a file
Awk -F '[=,:]' '{print / uid = /? 4: (/ ^ Telephone N /)? $ 2: $ 3} '1.txt The output is something like this
abcdefgt I get this output To a file 2.xml
& lt; Xml & gt; I would like to write in & Lt; Name & gt; Aaaa & lt; / Name & gt; & Lt; Surname & gt; Bbbb & lt; / Nickname & gt; ... & lt; / Xml & gt; & Lt; Xml & gt; & Lt; Name & gt; Eeee & lt; / Name & gt; & Lt; Surname & gt; Ffff & lt; / Nickname & gt; ... & lt; / Xml & gt; I do not know how to manage results with strange. Can you help me
I would like to see how your actual data looks like,
But it shows that your output shows 4 fields and your input shows 4 fields, here's the basic idea. awk 'BEGIN {RS = "" # lines The lines between the sets of data RecordSep FS = "\ n" #Receive each row (like $ 1, $ 2 ...) } {# This is the main loop, each record set is procssed here printf ("& lt; xml> gt; \ n \ t & lt; name & gt;% s & lt; / name & gt; \ n \ t & Lt; nickname & gt;% s & lt; / surname & gt; \ n \ t & lt; addr1 & gt;% s & lt; / Addr1 & gt; \ n \ t & lt; Addr2 & gt;% S & lt; / Addr2 & gt; \ n & lt; / xml & gt; ", $ 1, $ 2, $ 3, $ 4)} '1.txt & gt; 1.xml Note: Only 1 of your record sets should be empty.
I hope it will be helpful.
PS As you appear as a new user, if you get an answer that helps you to remember to mark it as acceptable, or it is useful Reply + (or -) as the answer.
Comments
Post a Comment