trimming out spaces in solaris


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting trimming out spaces in solaris
# 1  
Old 10-16-2009
trimming out spaces in solaris

friends,
I have a script in solaris 10 SPARC system which is like this

Code:
date '+Time: %m/%d/%y %H:%M:%S'
echo " GDBRR GDLRR  GDBWR GDLWR GDRRR GDRWR  "
sar -b 10 10 |/usr/xpg4/bin/awk  '!/Average/ && !/SunOS/ && !/bread/  {$1="";T=$2;T1=$3;T2=$5;T3=$6;T4=$8;T5=$9}{print(T"\t",
T1"\t",T2"\t",T3"\t",T4"\t",T5"\t" )}; '

The only glitch i am having here is there is a huge space between the headers and the values
as shown like this
Code:
Time: 10/16/09 16:26:34
 GDBRR GDLRR  GDBWR GDLWR GDRRR GDRWR




0        0       0       0       377     0
0        48      0       0       579     0
0        2       0       1       212     0
0        0       0       0       400     0
0        48      0       0       543     0
0        2       0       1       248     0

Pls guide me how to reduce the spaces and make the out put more readable
# 2  
Old 10-16-2009
You could try:

Code:
sar -b 10 10 |/usr/xpg4/bin/awk  '!/Average/ &&!/SunOS/ &&!/bread/ && !/^$/ {$1="";T=$2;T1=$3;T2=$5;T3=$6;T4=$8;T5=$9}{print(T"\t",
T1"\t",T2"\t",T3"\t",T4"\t",T5"\t" )}; '

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Multiple swap spaces after refresh Solaris 11.3 install on Sparc T5-2

Hi The following is the output of "df -h" and "zfs list" right after fresh installation of Solaris 11.3 on Sparc T5-2 with 256GB memory. Because the server has 256GB of memory, I think Solaris created swap file system mounted on /system/volatile and /tmp, but my question is, zfs also has... (5 Replies)
Discussion started by: jasonu
5 Replies

2. UNIX for Dummies Questions & Answers

Trimming ends

My files look like this I need to remove the sequence GGGAAA and anything before that I also need to remove the sequence AGCCCTA and anything after that So I will end up with something like this The left side is done but I cannot get the right side correctly. I would like to use... (3 Replies)
Discussion started by: Xterra
3 Replies

3. Shell Programming and Scripting

Trimming in between the words

Hi i have a log file P12345_15728710:DEBUG:Begin P12345_15728710:DEBUG:Being P12345_15729310:DEBUG:GetAgen P12345_15726510:DEBUG:end i want to trim this file and i want like this 15728710 15728710 15729310 15726510 i tried sed ..but not working.. sed "s/.*P12345__ \(.*\)... (4 Replies)
Discussion started by: navsan420
4 Replies

4. Shell Programming and Scripting

Trimming Spaces in Unix

Hi All, I am using following script to name the file base of some values #!/bin/sh sourcefile=$1 awk ' BEGIN{ n = 1; name = "FILEFILE12" n ".txt"; } { if (substr($0,1,10) == "FILEFILE12") { close (name) n++ a = substr($0,11,10); b = substr($0,21,5); name = b "_Src_" a ".txt" }... (6 Replies)
Discussion started by: manish8484
6 Replies

5. Shell Programming and Scripting

Trimming spaces from a variable

Hi guys, when I take substring of a particular data using this command var=substr($0,11,10) it comes with spaces, when I am trying to trim the spaces it is not allowing me to do that. Can you please help me out on that. As I have to reverse the output of the variable also. ---------- Post... (0 Replies)
Discussion started by: manish8484
0 Replies

6. Shell Programming and Scripting

How can I stop the unix script from trimming extra spaces?

I have a file which contains certain records about users. the row length is always fixed to 205 characters. Now I want to read each record line from the file, substring some portion out of it and put into another file. But I have observed that my script is trimming the extra spaces I have used for... (4 Replies)
Discussion started by: Pramit
4 Replies

7. UNIX for Advanced & Expert Users

Trimming the spaces

Hi, How can I remove the unwanted spaces in the line. 123456 789 ABC DEF. - I wanna remove the sapces in this line, I need the output 123456789ABCDEF. Pls help me...... (3 Replies)
Discussion started by: sharif
3 Replies

8. Shell Programming and Scripting

trimming white spaces

I have a variable that calls in a string from txt file. Problem is the string comes with an abundance of white spaces trailing it. Is there any easy way to trim the tailing white spaces off at the end? Thanks in advance. (9 Replies)
Discussion started by: briskbaby
9 Replies

9. Solaris

spaces trimming while assigning to a variable

Hi my lovely friends, Im writing one pgm in which i trying to assign some values like $var='Jun 6' but if i do echo of this $var will trim the spaces expect one space. $echo $var $Jun 6 But if var='Jun 28', then this will works fine $echo $var $Jun 28 this is required to exctract... (2 Replies)
Discussion started by: Lokesha
2 Replies

10. UNIX for Dummies Questions & Answers

trimming a file...

Hi everyone I have this script that appends a line to a file to log the running status of an application. I need to write another script to run as a scheduled job in cron to trim the first x number of lines of this file. Could someone give me an idea how to do this? Regards (1 Reply)
Discussion started by: alwayslearningunix
1 Replies
Login or Register to Ask a Question