469,270 Members | 1,239 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

Problem for picking & manipulating particular line from /PROC/DISKSTAS

HI!
I 'm working on linux .I hv difficulty for picking particular line from a file...
I like to make some manipulation on LINE such as
3 sda7 333333 66666 888888 444444
from file /PROC/DISKSTATS
how I should proceed???
PLZ reply me if u hv answer......
i m waiting.......
Aug 9 '07 #1
3 1710
prn
254 Expert 100+
I'm afraid I don't have an answer. The reason is that you haven't give me a well-formed question.

You want to pick a particular line from a file. OK. What criteria do you have to select the line? What kind of manipulation do you intend to do?

We can't tell you how to pick a line if we don't know why you want to pick one line rather than another.

Regards,
Paul
Aug 9 '07 #2
HI!
I 'm working on linux .I hv difficulty for picking particular line from a file...
I like to make some manipulation on LINE such as
3 sda7 333333 66666 888888 444444
from file /PROC/DISKSTATS
how I should proceed???
PLZ reply me if u hv answer......
i m waiting.......
manipulations are :
1.to check how values such as 3333333(in above line )
changes every second i.e.after sleep(1);
2.how i will separate every values in above line...
Aug 10 '07 #3
prn
254 Expert 100+
Hi prassaad,

manipulations are :
1.to check how values such as 3333333(in above line )
changes every second i.e.after sleep(1);
2.how i will separate every values in above line...
That's still not very clear. I'll make some assumptions. Assuming that you want to pick the line with sda7, your script can just grep for sda7. To separate the elements of the line, you can use cut. Also, note that the fields in /proc/diskstats are separated by an unknown number of spaces, as in:
Expand|Select|Wrap|Line Numbers
  1.  
  2.    3    1 hda1 1282 2570 23 46
  3.    3    2 hda2 244191 3961445 2621545 20972360
  4.    3   64 hdb 11056 4657 473450 256563 60696 17135 623128 330075 0 150236 586641
  5.    3   65 hdb1 15595 472418 77894 623128
so you may need to "squash" them together to get a single space. Thus, if I wanted to extract the field immediately following "hda2" in the excerpt above, I might write:
Expand|Select|Wrap|Line Numbers
  1. #! /bin/sh
  2. while [ true ]
  3. do
  4.     grep hda2 /proc/diskstats | tr -s ' ' | cut -d ' ' -f5
  5.     sleep 1
  6. done
Without knowing any more than you have told us, that's about the best anyone can do for you.

HTH,
Paul
Aug 13 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by pb648174 | last post: by
2 posts views Thread by Kent Lewandowski | last post: by
15 posts views Thread by Madhanmohan S | last post: by
reply views Thread by Will Asrari | last post: by
1 post views Thread by NeoGregorian | last post: by
1 post views Thread by Dan Upton | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.