Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change formatted file to unformatted 1

Status
Not open for further replies.

inunix

Technical User
Jul 30, 2002
53
US
Hi

I've a xml file, and i just want to unformat the whole file to something like data file(single line).

I used
xyz=`cat myfile.xml`;echo $xyz>trout. It does pretty good job, but it change few patterns to control characters.. like /00 & /e to some control characters...
below is a sample xml like file.

eg:
<?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?>
<test>
<money>$200</money>
<path>/usr/sdear/00123/efb001.txt</path>
</test>

Is there any way to get a output like the one shown below..(all in a line)
<?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <test> <money>$200</money> <path>/usr/sdear/00123/efb001.txt</path> </test>

Thanks.
 
tr '\n' ' ' < myFile.xml

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Thanks vlad.
I tried already this translate.. but still the output is not the one i expected(shown at the end in my initial thread). like single line...

it is coming like
<?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <test> <money>$200</money> <path>/usr/sdear/00123/efb001.txt</path> </test>

since money and path are not starting at the beginning of a line.. ????



 
try something like that:

sed -e :a -e '$!N;s/ *\n/ /;ta' -e 's/ */ /g' myFile.xml

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Your &quot;SED&quot; works perfect for me... Great.

Could you explain the various args/params you used in the sed.? Thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top