LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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!

Notices



Reply
 
Search this Thread
Old 01-17-2007, 09:02 AM   #1
keysorsoze
Member
 
Registered: Apr 2004
Location: Queens, NY
Distribution: Red Hat, Solaris
Posts: 295

Rep: Reputation: 30
Grepping a file for Text going down.


Hi! I am looking for a way to process info from a file from top down. For example

15:45:01 CPU %user %nice %system %iowait %irq %soft %idle intr/s
15:46:01 all 2.63 0.00 0.16 0.53 0.00 0.02 96.66 1141.81
15:47:01 0 6.92 0.00 0.36 0.52 0.01 0.07 92.11 376.26
15:48:01 1 1.26 0.00 0.09 0.72 0.00 0.00 97.94 256.74
15:49:01 2 1.39 0.00 0.12 0.78 0.00 0.00 97.70 254.60
15:50:01 3 0.94 0.00 0.06 0.10 0.00 0.00 98.90 254.21

How would I process the values for %soft straight down so I can get just a listing of 0.02, 0.07, 0.00, 0.00, 0.00 in a column format.
If I use awk how do I process the field since it is a random number.

Such as

awk '/15.46:01/ {print $8}' system_statistics | less will give me the value of that single line. How do I go about processing the entire column without specifying individual lines.


Thanks.
 
Old 01-17-2007, 09:28 AM   #2
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 53
I have some problem to understand your question
Quote:
Originally Posted by keysorsoze
How would I process the values for %soft straight down so I can get just a listing of 0.02, 0.07, 0.00, 0.00, 0.00 in a column format.
If I use awk how do I process the field since it is a random number.
Where is there a random number?
Quote:
Such as

awk '/15.46:01/ {print $8}' system_statistics | less will give me the value of that single line. How do I go about processing the entire column without specifying individual lines.
Thanks.
Mmmh
awk '{print $8}'
?

For column treatment there is also /usr/bin/colrm
 
Old 01-17-2007, 09:32 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,699
Blog Entries: 54

Rep: Reputation: 2962Reputation: 2962Reputation: 2962Reputation: 2962Reputation: 2962Reputation: 2962Reputation: 2962Reputation: 2962Reputation: 2962Reputation: 2962Reputation: 2962
...and w/o awk:
Code:
cat output | while read line; do 
 line=(${line}); case "${line[7]}" in 
  [0-9]*) echo "${line[7]}";; esac
done
 
Old 01-17-2007, 10:06 AM   #4
keysorsoze
Member
 
Registered: Apr 2004
Location: Queens, NY
Distribution: Red Hat, Solaris
Posts: 295

Original Poster
Rep: Reputation: 30
Thanks for the reply, I have obtained what I needed with your awk '{print $8}' command. However, I get a ton of values. How do I narrow them down to just a specific value such as the %idle cpu rate. I tried awk '{print $8}' | grep %idle but all I get is %idle %idle %idle. The goal is to just obtain the field:
%idle statistics.
96.66
92.11
97.94
97.70
98.90




This is a snapshot of a server for every 5 minutes so the file is huge

Here are the awk results:

awk '{print $8}'

%idle
96.66
92.11
97.94
97.70
98.90


TX-ERR
0
BMRU
BMRU
BMRU
BMRU
BMRU
BMRU
0

wkB/s
65.91

wkB/s
289.93

wkB/s
270.20

Last edited by keysorsoze; 01-17-2007 at 10:10 AM.
 
  


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
how to change some text of a certain line of a text file with bash and *nix scripting alred Programming 6 07-10-2006 12:55 PM
Which light text editor can copy text from file and paste in browser? davidas Linux - Software 9 03-06-2006 12:28 PM
SED - display text on specific line of text file 3saul Linux - Software 3 12-29-2005 05:32 PM
grepping unknown text, is there a way? vdemuth Programming 15 09-26-2005 04:00 AM
How to find and change a specific text in a text file by using shell script Bassam Programming 1 07-18-2005 08:15 PM


All times are GMT -5. The time now is 09:49 AM.

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