?
Solved

Split the line into multiple line based on delimeter using script

Posted on 2008-10-18
3
Medium Priority
?
324 Views
Last Modified: 2013-12-26
Input file

xxx,yyy,zzz,1
vvv,mmm,ppp,bbb,lll,3
jjj,rrr,4


I need the following utput
xxx,1
yyy,1
zzz,1
vvv,3
mmm,3
ppp,3
bbb,3
lll,3
jjj,4
rrr,4

Need to split each line into multiple lines based on delimeter , except last column .Last column shoud append to each spillted line

0
Comment
Question by:sumanth_ora
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 2000 total points
ID: 22749735

awk -F, '{for (i=1; i<NF; i++) printf "%s,%d\n",$i,$NF}' file

Open in new window

0
 

Author Comment

by:sumanth_ora
ID: 22749943
here we need to rea from file1 & shoul write to file2

Can we modify like this


 awk -F, '{for (i=1; i<NF; i++) printf "%s,%d\n",$i,$NF}' file1 >> file2
 
0
 
LVL 48

Expert Comment

by:Tintin
ID: 22750276
Yes, but keep in mind that >> means append to file.  If you want to create/overwrite it, use >
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question