Solved

Process a line of variable length using AWK

Posted on 2004-09-23
2
259 Views
Last Modified: 2013-12-26
Dear All,
    I have a line which has a viriable number of fields(comma seperated fileds) from time to time and I want to run an awk on it to print those fields each in a separate line.
    For a line of constant number of fields that is quite managable but anyone can guide me how to manage a line of variable number of fields.
   Thanks
0
Comment
Question by:A_HASSAN
[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 Comments
 
LVL 21

Expert Comment

by:tfewster
ID: 12138830
awk -F"," '{for (i = 1; i <= NF; i++) {print $i}}' filename.txt
0
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
ID: 12138835
awk -F, '{for (i=1; i<=NF; i++) printf("%s\n",$i)}' file.csvt
0

Featured Post

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

623 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