Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I have a big file (with more fields) like this:
Username: John Wright
Compony: New Consultancy
I am able to do this using awk . But it is taking long time to achieve. Is there any better way to do using Tcl, perl or awk ?
Well, perl *CAN* do it, but the question back is, why re-write what's already working? If you can do this with awk, let it run and be finished with it. The only real need to rewrite this would be if you had to run this very often, and the file was always growing, and how MUCH time it takes.
If you have to run it once a week, and even if it takes 20 minutes to run, and you've already got it working, that's a project to save for a rainy day. If you have to run it five times a day...that's different.
If I were to do it in perl (which I would), I'd probably use the split directive, and split the fields on the ":". You'd wind up with two variables, the description and value, like "Username" and "John Wright". From there, you could then output the data to an output file easily. Test variable one to see what it is, then set variable 2 accordingly. The good part of that is if you have to re-order the output (such as putting the Company first), all you've got to do is edit one line of the Perl script. Similarly easy to modify the input...just put a new test in to add new fields, and even if the data starts coming at you in a different order, the tests will catch it, and put it right.