Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 02-20-2013, 02:14 PM   #1
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!
Old 02-20-2013, 05:30 PM   #2
Senior Member
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
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, 08:13 PM   #3
Registered: Sep 2008
Location: The Netherlands
Distribution: Slackware64 current
Posts: 589

Rep: Reputation: 132Reputation: 132
use ksar
Old 02-21-2013, 12:28 AM   #4
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.7, Centos 5.10
Posts: 16,925

Rep: Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215
If you do want to learn Perl (and its very powerful):

As above, ksar is worth a look also.


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

All times are GMT -5. The time now is 12:13 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration