Can I please get a push in the right direction with awk/sed?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can I please get a push in the right direction with awk/sed?
# 1  
Old 05-16-2016
Can I please get a push in the right direction with awk/sed?

Hi Guys,

I have this task to monitor a linux box. I found a program that displays the parameters that I want and I wrote a little .sh to run that program and record output into a file.

The findings look promising but I would like to graph them.

My output (for every iteration) looks like this:


Code:
blablabla (some guy bragging about his program and version)

05/16/16 16:50:58
Name            Param1  Param2 
one                     1.0        1.1
two                     2.0        2.1

I want, instead of my .sh making this program dump the output in the raw form, to take just the timestamp and the numbers, resulting in something like this:
Code:
16:50:58,1.0,1.1,2.0,2.1

(then, I could run this every minute for 2-3 hours and have a csv that I could graph)

Linux shell scripting is really out of my career scope at the moment.

What do I use here? gawk/sed? Maybe a clever grep?
If you could please just show me how to do it for one value, I will figure out the rest.





Moderator's Comments:
Mod Comment Please use code tags as required by forum rules!

Last edited by DraxDomax; 05-16-2016 at 02:31 PM.. Reason: Added code tags.
# 2  
Old 05-16-2016
That specification is a bit sparse. Does the file consist of a time stamp, a header line, and two parameter lines always? Does it contain these records only? Always the same structure?
# 3  
Old 05-16-2016
To be exact, the output is such:

Code:
Linux 3.12.28-4-default (machine-name)     05/16/16     _x86_64_    (4 CPU)

05/16/16 16:50:58
Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
scd0              0.00         0.00         0.00       1598          0
sdb               0.46         0.31        11.56     468944   17228724
sda               0.82         0.25        27.99     379696   41709248

It's always the same structure and the Devices are always the same




Moderator's Comments:
Mod Comment Please use code tags as required by forum rules! Seriously!

Last edited by RudiC; 05-16-2016 at 02:42 PM.. Reason: Added code tags (again!)
# 4  
Old 05-16-2016
In absence of some adequate logics, try
Code:
awk 'NF == 2 {if (L) printf RS; printf "%s", $2; L = 1; next} /Name/ {next}; {printf ",%s,%s", $2, $3} END {printf RS}' file
16:50:58,1.0,1.1,2.0,2.1

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk print re-direction to a file with timestamp appended

Hello I need to split big xml file into multiple files based on xml declaration. for that i have written one awk 1 liner as below awk '/<?xml\ version/{i++}{print > "outfile."i}' test123.xml this is producing the desired out put. but i want the the currenttimestamp with milliseconds in the... (3 Replies)
Discussion started by: dsdev_123
3 Replies

2. AIX

New to aix virtualization direction ?

picked up a 9111-520 p5 hardware recently with 8 Gig of RAM, lots of internal disk space...6 x 140 gig had 7.1 pre-installed, and managed to upgrade the firmware to latest SF240_xxxx goal is to virtualize this and have LPARs running aix 7.1, 6.x, and Rhat for ppc .. need some... (13 Replies)
Discussion started by: ppchu99
13 Replies

3. Shell Programming and Scripting

Direction to create website to process grep and SED requests

hi I am seeking to create a cgi-bin type creation that will allow users browsing the site to be able to run searches that would be a grep command or SED in the backround. I am not sure how to go about this, if you would give me a pointer or direction about what technology i could inform myself... (0 Replies)
Discussion started by: cdc01
0 Replies

4. Fedora

In need of some direction

Okay, so I'm not a complete newb when it comes to using Unix/Linux. I've been using Ubuntu for a few years now and I've dipped my toes into a few other distros but now I want to get a bit serious. I'm looking at becoming a sysadmin but the trouble is...I have no idea where to start. What I'm... (1 Reply)
Discussion started by: Tamachan87
1 Replies

5. Shell Programming and Scripting

Finding when a file switches direction using awk

Hi guys I have a file that is filled with x,y values: 0.000000 0.00129578 0.000191 0.00272187 0.000381 0.0125676 0.000572 0.0120014 0.000763 0.00203461 0.000954 0.00682248 0.001144 0.00202773 0.001335 0.000840523 0.001526 0.00451419 ....5MB of that I wanted to know if there is a... (7 Replies)
Discussion started by: bflinchum
7 Replies

6. Fedora

Need Direction for extra work ?

Hey , I have become pretty normal, using unix and what not and working around FEDORA 9 I was wondering does anyone have any IDEAS or have anything I should try to build or scripts to write , or possibly know any sites where I could practice some things just so I know I am writing them... (2 Replies)
Discussion started by: Producer
2 Replies

7. Shell Programming and Scripting

re-direction

Say I have a single bin directory with Linux and SunOS executables, like this: bin/myprog_lnx bin/myprog_sun Assume these programs read from stdin and write to stdout and, thus, are meant to be run like this: myprog_lnx < filein > fileout My users may log in from a Linux or Solaris... (3 Replies)
Discussion started by: gsal
3 Replies

8. Programming

In what direction should I take computer programming?

I'm a senior in high school trying to start getting into computer programming. All I've done so far is picked up a book on C for beginners and started to teach myself. There aren't really any courses at my high school for introductory programming, so it looks like I'll have to wait for college to... (7 Replies)
Discussion started by: Fritzz
7 Replies

9. UNIX for Dummies Questions & Answers

New & could use some direction!

First, I just rebuilt/installed my custom kernel & I don't know how to check if it ran properly (I'm fairly sure it did, but I'm looking for reassurance that it loaded the new kernel file). Second, I'd love to get into programming, scripting, whatever, I want my imagination to be the builder &... (2 Replies)
Discussion started by: LazySpoon
2 Replies
Login or Register to Ask a Question