LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-21-2004, 10:42 PM   #1
laikos
Member
 
Registered: Nov 2002
Distribution: Slackware 8.1
Posts: 30

Rep: Reputation: 15
Question sed/awk for matching & substituition


Hi,
I would like to write a sed or awk script to do conversion for
/proc/partitions information to format that is understoodable by most people

Code:
# cat /proc/partitions
major minor  #blocks  name     rio rmerge rsect ruse wio wmerge wsect wuse running use aveq
   8    48   17921835 scsi/host1/bus0/target2/lun0/disc 294 187 3818 1450 3 0 24 0 0 1440 1450
   8    49   17920476 scsi/host1/bus0/target2/lun0/part1 293 184 3810 1450 3 0 24 0 0 1440 1450
   8    64   17921835 scsi/host1/bus0/target3/lun0/disc 8537 3 68284 40720 1 0 8 0 0 17940 40720
   8    65   17920476 scsi/host1/bus0/target3/lun0/part1 8536 0 68276 40710 1 0 8 0 0 17930 40710
   8    80   17958274 scsi/host1/bus0/target4/lun0/disc 2077 31422 267956 68450 1 0 8 0 0 38700 68450
   8    81   17952606 scsi/host1/bus0/target4/lun0/part1 2076 31419 267948 68450 1 0 8 0 0 38700 68450
from this information I want to convert it to format such as
Code:
/dev/sda
/dev/sda1
/dev/sda2
In doing that I believe the code should be able to do conversion
[0..25] -> [a..z]

Thanks for your help
 
Old 11-22-2006, 10:00 AM   #2
zefo
Member
 
Registered: Mar 2003
Posts: 71

Rep: Reputation: 15
probably a bit outdated reply but cat /proc/partitions on my system (archlinux 7.2) is:

3 0 39483743 hda
3 1 394834 hda1
3 2 938493 hda2
.
.

so i think no filtering is needed.
 
Old 11-22-2006, 11:19 AM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,977
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Not only is this outdated, it doesn't match his system; he's is (was?)
using devfs on a Slackware machine.


Cheers,
Tink
 
Old 11-22-2006, 11:44 AM   #4
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
Since sudo fdisk -l does the conversion already, perhaps:
sudo /sbin/fdisk -l | awk '/^\/dev/ {print $1}'

You could edit the sudoers file (with visudo normally) to use this oneliner.
 
  


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sed & Awk hinetvenkat Linux - Software 4 05-30-2005 05:10 AM
awk and sed issues alaios Linux - General 11 03-24-2005 05:33 AM
awk: /matching/ variables passed with -v aunquarra Linux - General 2 02-17-2005 06:47 PM
awk/sed help pantera Programming 1 05-13-2004 11:59 PM
Tutorial on sed & awk LinuxTiro Programming 4 11-10-2003 03:53 AM


All times are GMT -5. The time now is 08:26 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration