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.
This would give me something like:
Since I'm pxe booting a limited shell, i'll have grep and mawk at my disposal. I'm not sure what else I would need since I don't know what is available in this shell until i try it.
I basically want to take the "sda" out of the line "/dev/sda: 10485760" and assign "sda" to a variable that I can use throughout the /bin/sh program.
We'll assume we only have one type of drive per system which means it will be either sda, hda, cciss, etc....
How can I do this?
Some background info: I'm trying to customize a systemimager script to recognize the drive automatically...so whether it is scsi, hp scsi device, sata, pata...i want to be able to automaticaly recognize what device to use in order to create the partitions, fstab file, and boot loader config file in the script. This comes in hand when having 1 OS being installed onto different hardware.
Wow! HTF did you figure out the -F "[ :/]" part? -- I re-read the gawk info page regularly & everything I have seen there strongly implies that -F takes a 1 character value. Of course the fact that the IFS environment variable is multi-character might be a hint, but everything overt in that <expletives_deleted /> info page says the opposite. AFAIAC, this is a bug in the documentation or else the authors aren't aware of this capability.
BTW, this works in mawk, which is a separate program on my MEPIS box, & in awk in "traditional" mode:
You now have multiple good answers of varying length & precision, your choice will be according to what will work in the variety of environments you expect your script to encounter; and, to a lesser extent, perhaps to aesthetics.
In my mind, the major unknown is the limits on sfdisk output. -- Are all /dev/'s 3 characters w/ a 'd' in the middle? If this is so, always so, it radically simplifies the design of the parsing regex. If it is true today, will it stay that way?
W/o reading the source, the best indicator may be:
$ strings `which sfdisk` |grep -i dev |less -N
... (excerpt from less' output)
9 device: something like /dev/hda or /dev/sda