Need unix/linux command


 
Thread Tools Search this Thread
Operating Systems Linux Need unix/linux command
# 1  
Old 06-29-2012
MySQL Need unix/linux command

Hi,

When i ran the command as sar in linux box. i got a output like as below

Code:
[spt@scrbgcddkcph431 tools]$ sar
Linux 2.6.18-274.3.1.el5 (scrbgcddkcph431)      06/29/2012

12:00:01 AM       CPU     %user     %nice   %system   %iowait    %steal     %idle
12:10:01 AM       all           8.78       0.00      26.11       3.80         0.00        61.30
12:20:01 AM       all           3.09       0.00      5.12         1.13         0.00        90.65
12:30:01 AM       all           1.03       0.00      1.69         0.04         0.00         97.23

But i would like to convert from above output to mentioned below one.

Code:
Linux 2.6.18-274.3.1.el5 (scrbgcddkcph431)      06/29/2012

12:00:01       %user     %system   %iowait    %idle
12:10:01       8.78       26.11       3.80          61.30
12:20:01       3.09       5.12         1.13          90.65
12:30:01       1.03       1.69         0.04          97.23

Please advice on this.

Last edited by Scrutinizer; 06-29-2012 at 04:16 AM.. Reason: code tags
# 2  
Old 06-29-2012
Code:
$ awk '{$2=""; $3=""; print}' infile

# 3  
Old 06-29-2012
Code:
 
$ sar | awk 'NR>2{$2=$3=""}1'
Linux 2.6.18-274.3.1.el5 (scrbgcddkcph431)      06/29/2012
12:00:01   %user %nice %system %iowait %steal %idle
12:10:01   8.78 0.00 26.11 3.80 0.00 61.30
12:20:01   3.09 0.00 5.12 1.13 0.00 90.65
12:30:01   1.03 0.00 1.69 0.04 0.00 97.23

# 4  
Old 06-29-2012
Hi jayan and kamaraj..

Thank you for your's quick response.. But i would like proper alignment as well. Because i am going to store those entry into one file. then will read from that file in php ...

Please help on this
# 5  
Old 06-29-2012
Checkout the command printf and if it does not work, show your tries please.
# 6  
Old 06-29-2012
Code:
 
$ sar |nawk -v OFS="\t" 'NR>2{$2=$3=""}1'
Linux 2.6.18-274.3.1.el5 (scrbgcddkcph431)      06/29/2012
12:00:01                        %user   %nice   %system %iowait %steal  %idle
12:10:01                        8.78    0.00    26.11   3.80    0.00    61.30
12:20:01                        3.09    0.00    5.12    1.13    0.00    90.65
12:30:01                        1.03    0.00    1.69    0.04    0.00    97.23

# 7  
Old 06-29-2012
Code:
 
 sar | awk 'NR>2{$2=$3=""}1' | column -t

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Simple sed command not working; could be a Mac/Linux vs. PC/Linux issue

Hello, I am on a Mac and trying to clean up some monthly files with a very simple SED: sed '3,10d;/<ACROSS>/,$d' input.txt > output.txt (from the input, delete lines 3 - 10; then delete from the line containing <ACROSS> to the end of the file) then output to output.txt Even when I try... (2 Replies)
Discussion started by: verbatim
2 Replies

2. Shell Programming and Scripting

How to use expect and send command in UNIX/Linux?

Hello Everyone, I am executing a unix script which logs into 50+ servers (netapp servers) and runs some commands and captures output locally. Below is the code snippet. file1.txt has names of all the remote servers where I am logging in. #!/bin/ksh #!/usr/bin/expect touch... (1 Reply)
Discussion started by: rahul2662
1 Replies

3. Fedora

Which is the better platform to learn UNIX/Linux (Kali Linux Vs. Red Hat or other)?

I just started a new semester and I started my UNIX class yesterday. I've already decided to use python along with my learning process but what I really want to use with it is Kali as my UNIX/Linux platform to learn off of since I already wanted to learn Cyber Sec. anyways. I just wanted to know if... (12 Replies)
Discussion started by: ApacheOmega
12 Replies

4. HP-UX

Linux to UNIX command

Hi, I have the below command for Linux find -iname '*.ear' -o -iname '*.war' | xargs grep -R org.apache.log4jWhat is the HP-UX equivalent of this ? (4 Replies)
Discussion started by: mohtashims
4 Replies

5. UNIX for Dummies Questions & Answers

install command flag Linux/Unix issue

Hi all, I was trying to install from source USB_ModeSwitch on my Mac. I have always had success with the basic ./configure, make, make install commands in terminal so don't know how, why or what. The issue I came across is that the makefile.conf uses the -D flag while installing and on UNIX... (0 Replies)
Discussion started by: jprokos
0 Replies

6. Shell Programming and Scripting

Stress testing php files at Unix/Linux Command line

Hi, Your great help is very appreciated. I am looking for any Unix command or tool for doing Stress/Load test of php files at command prompt. I tried torture.pl but it is not working after20 concurrent threads/users. as it is very urgent for me..please suggest ur ideas asap. thanks (5 Replies)
Discussion started by: Malleswari
5 Replies

7. UNIX for Dummies Questions & Answers

su command difference between unix and linux

Hello all the su with -l option is running normal with linux but when i try to run it on unix AIX 5.2.7 it's not working with -l option any help (6 Replies)
Discussion started by: islam.said
6 Replies

8. UNIX for Dummies Questions & Answers

How to convert this linux command to Unix AIX?

How to convert this linux command to Unix AIX? I have tried this command and work in CentOS: tail --line=0 --retry -f --follow=name --max-unchanged-stats=1 logFile.log But in AIX, the tail haven't "--retry" "--follow=name" option. Thanks in advance. (1 Reply)
Discussion started by: chris13work
1 Replies

9. Programming

writing your own command in unix/linux

Hi I am very new to Linux programming,otherwise I have exposure to Linux. Was thinking about something like writing my own commands for Linux. Any ideas where to start, any useful links and what I need to know before I start with this. Thanks :) Sidhu (3 Replies)
Discussion started by: Amardeep
3 Replies
Login or Register to Ask a Question