473,387 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 1833
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

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

Similar topics

1
by: Brad H McCollum | last post by:
I'm writing an application using VB 6.0 as the front-end GUI, and the MSDE version of SQL Server as the back-end (it's a program for a really small # of users --- less then 3-4). I'm trying to...
7
by: pb648174 | last post by:
I am trying to add a column to a temp table and then immeditaely query against that new column. If I do this in Query Analyzer it works fine as long as there is a go in between, but I can't use a...
2
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
3
by: Chris | last post by:
Modal forms are great for locking the user out of non focused forms allowing tight control over program flow, but they have one side effect which user find very irritating i.e. Access cannot be...
15
by: Madhanmohan S | last post by:
Hi All, I want to run a command line appplication from C#. When i start the application, it will go into specific mode. After that, i have to give commands to use the application. How Can This Be...
0
by: Will Asrari | last post by:
In my code I have created a Process for opening up a command line executable using System.Diagnostics.Process that imports a csv full of Generic Authorization account information to numerous tables...
1
by: ARC | last post by:
I have some functions that will allow a user to attach to a different back-end database. I added this functionality to the program Ribbon in a custom Access 2007 app. I have 2 ways to attach to a...
1
by: NeoGregorian | last post by:
Hello, I am writing a wrapper to a basic Input/Output programs (where you type a one line command at a time and then get 0 or more lines of output before you can input the next command). I'm...
1
by: Dan Upton | last post by:
Or: How to write Python like a Python programmer, not a Java programmer. This will be a little long-winded... So I just recently started picking up Python, mostly learning the new bits I need...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.