Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Process a line of variable length using AWK

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

688 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