The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
PERL:How to convert numeric values txt file to PACKED DECIMAL File? aloktiwary Shell Programming and Scripting 1 05-20-2009 09:55 AM
Convert CSV file (with double quoted strings) to pipe delimited file lehmanbrothers Shell Programming and Scripting 11 02-13-2009 01:14 PM
convert one colume file to a one line, wrapped file. jouuu UNIX for Advanced & Expert Users 7 12-03-2008 06:07 AM
Plz Help To convert xml file to text file using bourn shell scripts ram2s2001 Shell Programming and Scripting 0 11-09-2005 09:56 AM
convert XML file into Text file(fixed length) ram2s2001 Shell Programming and Scripting 0 11-03-2005 01:28 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-24-2009
Hemantgupta84 Hemantgupta84 is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 4
How to convert a txt file to xml file

Hello,

I donot have exact lenght of the file.
But i want entire txt of the file to send it into one node.

for example I have txt file..
asdfghjklmnbvcxzqwertyuiop[]., nswwneikniniwn

so i need the output as

<documentbody>asdfghjklmnbvcxzqwertyuiop[]., nswwneikniniwn</documentbody>

iI have to convert this txt file into xml file using shell script



Thanks and Regards
Hemant

---------- Post updated at 01:43 AM ---------- Previous update was at 12:29 AM ----------

Please help..as I have to complete this work today as this is critical.

Last edited by Hemantgupta84; 08-24-2009 at 02:43 AM..
  #2 (permalink)  
Old 08-24-2009
durden_tyler's Avatar
durden_tyler durden_tyler is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2009
Posts: 519
... sorry, got it wrong...
  #3 (permalink)  
Old 08-24-2009
Hemantgupta84 Hemantgupta84 is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 4
Thanks for ur reply....

But this hard coded evertime a new file will be there when this script is called.
Also will this perl script work in Unix SAP Netweaver system.
  #4 (permalink)  
Old 08-24-2009
Franklin52 Franklin52 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,294
Quote:
Originally Posted by Hemantgupta84 View Post

Please help..as I have to complete this work today as this is critical.
If you have one file and if it's so critical, why don't simply use an editor?
  #5 (permalink)  
Old 08-24-2009
Hemantgupta84 Hemantgupta84 is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 4
Thanks for ur suggestion.
I know how to change .txt file manually or using editor.

But i need automate the system. Everytime a file came to unix box its get converted into xml. And i a min 1000 file can come.

THanks and Regards
Hemant
  #6 (permalink)  
Old 08-24-2009
blitzer blitzer is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 7
Code:
echo "<documentbody>$(cat infile.txt)</documentbody>" > outfile.txt
  #7 (permalink)  
Old 08-24-2009
malcomex999 malcomex999 is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 151
Or with awk...
Code:
 
awk 'BEGIN{print "<documentbody>"}{print $0}END{print "</documentbody>"}' infile
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:39 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0