ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i am reading a database flat file with the "awk" command which has 4 fields separated by colon ":" .I want to show the output of these fields in a certain way that every record is numbered e.g
1.some text
2.some text
Is there a way to do this?Any suggestions would be highly appreciated.
I don't see the correlation between the question you asked (regarding the 4 fields separated by colons) and the desired output you showed in your example.
If you simply want to display a file, showing the contained colon-separated-values on a line-by-line basis, why won't `cat -n` work? Further, pipe the output of `cat -n` into awk of you want to do something more to it.
If I have missed the point, please explain more, perhaps with a more "realistic" example, showing the sort of output you desire, including how the output is to be numbered as well as how the "4 colon separated fields" are to be displayed.
Best regards,
Sasha
EDIT: P.S. perhaps I'm not understanding the initial format of this "flat file" so if that appears to be the case, please also describe the file, it is something other than some sort of ascii file.
Last edited by GrapefruiTgirl; 03-25-2010 at 06:57 PM.
Thanks for replies, here is the detail:
my original file looks like this:-
A100:Annie Marie's Dance Academy:123:1500
F110:Frankies Repair Shop:1123:250
S100:Sandra's Counselling Service:67:500
A100:Annie Marie's Dance Academy:254:500
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.