LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-22-2007, 01:05 AM   #1
ElectroLinux
Member
 
Registered: Feb 2004
Posts: 74

Rep: Reputation: 15
i'd like to parse the ouput in shell


i'd like to parse the ouput of
sfdisk -s

This would give me something like:
/dev/sda: 10485760
total: 10485760

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.
 
Old 05-22-2007, 06:24 AM   #2
traene
Member
 
Registered: Jan 2005
Distribution: Archlinux, Debian, Centos
Posts: 222

Rep: Reputation: 35
don't know if this helps but maybe try:

Code:
 echo $( sfdisk -s|grep -e sda1) |awk ' { print $1 } '
sh may do this. if the $() does not work, try backticks '`'
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to ouput ls result Cigar Linux - General 2 03-06-2007 09:41 AM
ssimple shell script to parse a file ~sed or awk stevie_velvet Programming 7 07-14-2006 03:41 AM
Noise in tv sound ouput erpe Linux - Hardware 3 04-25-2006 05:53 PM
question about ouput of ls -l Itzac Linux - Newbie 1 05-09-2004 04:18 PM
How to read ans parse MS word file using a Linux Shell script. Alek Linux - General 2 11-10-2003 02:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration