ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
My goal is for the script to accept user input (which will be from column 1) and the script to check column 2 to see what OS type it is and then the script echoes headings dependant on what was found in column 2 followed by the data in columns 3 and 4.
so for example if USR1 was inputted I want the following output:
Linux User Name: Steven1
but if USR4 was inputted I want:
Windows User Name: Kate4
Windows Version: WinXP
I'm guessing awk or grep must be used somewhere, am I right - I've googled but I just can't seem to find exactly what I need.
Last edited by Inbhir Pheofharain; 05-05-2009 at 04:57 AM.
Reason: Forgot user name Kate4 on code example
ghostdog74's implementation is probably superior, in that one presumes that the Python module (csv) that he specifies would know how to deal with commas that can be embedded in the fields of a CSV file. If you can guarantee that your CSV file does not contain any such condition, then the solution given by colucix should suffice. For what it's worth, there is a comparable Perl module for parsing CSV files, should you prefer Perl as your implementation language.
ghostdog74's implementation is probably superior, in that one presumes that the Python module (csv) that he specifies would know how to deal with commas that can be embedded in the fields of a CSV file.
that's why i use csv module to handle such cases of embedded commas. eg
# more file
Enter user: usr1
Linux user name: Steven1,one
maybe troublesome is too strong but i think the awk solution is both faster in implimentation and execution.
when i graduated in ece/ cs, java was kinda' slow (its more resource intensive considering jvm is an emulation layer) i know it is much faster now due to tighter coding in jvm's as well as better processors.
i usually relegate java to gui swing stuff and c to text data manipulation but that's just my personal tastes.