Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Process a line of variable length using AWK

Posted on 2004-09-23
2
Medium Priority
?
262 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 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 2000 total points
ID: 12138835
awk -F, '{for (i=1; i<=NF; i++) printf("%s\n",$i)}' file.csvt
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

824 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