LinuxQuestions.org
Visit the LQ Articles and Editorials section
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 02-20-2013, 01:14 PM   #1
LymanYucius
LQ Newbie
 
Registered: Feb 2013
Location: Palmdale
Posts: 1

Rep: Reputation: Disabled
Parsing sar output text file, tab delimited


Just hired onto law firm IT team and gave me a flat file with sar command output that is roughly 1+ MB (contains cpu, memory, network and other stats). I heard perl is good to parse the necessary information but unsure how to go about this since a noob to programming in general.

The files sit on a linux server (v2.6) in the following file structure: mainfolder | subfolder(abcd format)| subfolder(yyyymm format )| File (ab00 format).
What I need to do:
Tell script to run on specific folder for a given date
Make tab delimited file comma delimited for import into excel (graph)
Parse specific information eg: memory
An example of sar output file for memory:
00:00:01 kbmemfree kbmemused %memused kbbuffers kbcached kbcommit %commit
00:10:01 513224 71524200 99.52 1724160 49148988 14336464 23.33

Any help with this would be greatly appreciated!
-Lyman
 
Old 02-20-2013, 04:30 PM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,630
Blog Entries: 3

Rep: Reputation: 345Reputation: 345Reputation: 345Reputation: 345
Well, it sounds like you want to read the folder from the command line, use sed to replace tabs with spaces then redirect the output to a file. It then sounds like you would want to use awk to print out only the columns you want.

If you have a more specific question/problem, or don't understand part of my suggestions, then feel free to ask! Good luck...

Hope this helps,
 
Old 02-20-2013, 07:13 PM   #3
whizje
Member
 
Registered: Sep 2008
Location: The Netherlands
Distribution: Slackware64 current
Posts: 583

Rep: Reputation: 129Reputation: 129
use ksar
 
Old 02-20-2013, 11:28 PM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,269

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
If you do want to learn Perl (and its very powerful):
http://perldoc.perl.org/
http://www.perlmonks.org/?node=Tutorials
http://www.tizag.com/perlT/index.php

As above, ksar is worth a look also.
 
  


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
[SOLVED] Parsing delimited file rexjenny Programming 2 07-09-2011 09:33 AM
[SOLVED] Parsing delimited file and variable scripting. mmcc0912 Linux - General 3 09-25-2010 01:49 PM
searching pattern in tab delimited file using grep vaibhavs17 Programming 5 03-05-2010 01:02 AM
Parsing a tab delimited text file jajanes Programming 9 08-08-2003 10:34 AM


All times are GMT -5. The time now is 03:10 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