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
to break a file into 2 files after matching a pattern. manit UNIX for Dummies Questions & Answers 3 04-01-2009 11:12 AM
Extract specific pattern from a file athreyavc Shell Programming and Scripting 4 11-12-2008 04:35 AM
Adding specific text and spaces to each line in a text file hertingm Shell Programming and Scripting 4 08-25-2008 02:34 PM
search and replace a specific text in text file? santosham UNIX for Dummies Questions & Answers 4 06-25-2008 05:53 PM
Removing parts of a specific field kieranh Shell Programming and Scripting 9 09-28-2007 12:52 PM

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
  #8 (permalink)  
Old 1 Week Ago
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,291
Code:
awk -F"[<>]" '/fileName/{f=$3".xml"}{print > f}' file
Explanation:

Code:
awk -F"[<>]"			# set fieldseparators
'/fileName/{f=$3".xml"}		# if current line contains fileName, change filename (field 3 ".xml")
{print > f}			# print file to filename
' file
Have a read of one of the awk tutorials here:

Unix Tutorials/Programming Tutorials/Shell Scripting Tutorials
  #9 (permalink)  
Old 1 Week Ago
abhinav192 abhinav192 is offline
Registered User
  
 

Join Date: Nov 2009
Posts: 25
The job has been done, but the only thing left is that the xml that i sgetting generated is also having the filename tag

Can we generate the xmls starting from <<?xml version="1.0" encoding="utf-8"?>>

rather than <fileName>Name1</fileName> tag

This is required because the xml thus generated is getting corrupted because of that filename tag
  #10 (permalink)  
Old 1 Week Ago
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,291
Quote:
Originally Posted by abhinav192 View Post
The job has been done, but the only thing left is that the xml that i sgetting generated is also having the filename tag

Can we generate the xmls starting from <<?xml version="1.0" encoding="utf-8"?>>

rather than <fileName>Name1</fileName> tag

This is required because the xml thus generated is getting corrupted because of that filename tag
Something like this?

Code:
awk -F"[<>]" '/fileName/{f=$3".xml";sub(".*fileName>","")}{print > f}' file
Sponsored Links
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 10:36 PM.


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