Solved

Process a line of variable length using AWK

Posted on 2004-09-23
2
257 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
2 Comments
 
LVL 20

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

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 …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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 an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 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