Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

Process a line of variable length using AWK

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
A_HASSAN
Asked:
A_HASSAN
1 Solution
 
tfewsterCommented:
awk -F"," '{for (i = 1; i <= NF; i++) {print $i}}' filename.txt
0
 
TintinCommented:
awk -F, '{for (i=1; i<=NF; i++) printf("%s\n",$i)}' file.csvt
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now