tab char appearing as single space?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers tab char appearing as single space?
# 1  
Old 05-30-2009
tab char appearing as single space?

I'm trying to run a script which will ssh to several other servers (All Solaris 10) and execute a sar -f command to get each server's CPU usage for a given hour.

It kinda works OK but I just can't figure out how to separate the returned fields with a Tab character. I've done lots of searching on the net but everything I've tried results in my output being only space delimited.

Here's what I've got ....
Code:
#!/usr/bin/ksh
#set -x
 
day=`date +%d`
hour=`date +%H`
 
if [ $hour -eq 00 ]
then
        comhour=23
        day=`(TZ=GMT+24;date +%d)`
else
        comhour=`expr $hour - 1`
 
        if [ $comhour -le 9 ]
        then
                comhour=`print 0`$comhour
        fi
fi
 
for Server in `cat server.list`
do
        print `ssh $Server "sar -f /var/adm/sa/sa$day | grep ^$comhour" 2>/dev/null | grep -v [a-z] | awk 'BEGIN { OFS="\t" } {print 100-$5"%",$1 }' | sort -n 
| tail -1`  $Server 
done

The output is like this ....

Code:
15% 22:55:00 ss44par01
7% 22:05:00 ss44par02
2% 22:35:00 ss44par03
22% 22:10:00 ss44par04
3% 22:10:00 ss44par05

but I want it like this ...
Code:
15%    22:55:00    ss44par01
7%     22:05:00    ss44par02
2%     22:35:00    ss44par03
22%    22:10:00    ss44par04
3%     22:10:00    ss44par05

Can anyone see where I'm going wrong?


Thanks very much.

--
Jake
# 2  
Old 05-31-2009
Did I ask the question wrongly somehow? Or just nobody knows the answer?
# 3  
Old 06-02-2009
One simple way would be:
( ./script )| tr -s " " "<press tab here>"
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Replacing multiple special chars with single char

Hi I've a string . And i need to replace set of characters with a single character Means .. or . or ... and so on should be replaced with single % character Irrespective of number of dots in between the characters , those should be replaced with single % All the above strings should be... (3 Replies)
Discussion started by: smile689
3 Replies

2. Shell Programming and Scripting

Single char

Task 2: When Im tring script called char that checks a single character on the command line, c. If the character is a digit, digit is displayed. If the character is an upper or lowercase alphabetic character, letter is displayed. Otherwise, other is displayed. Have the script print an error... (0 Replies)
Discussion started by: Roozo
0 Replies

3. UNIX for Dummies Questions & Answers

Changing only the first space to a tab in a space delimited text file

Hi, I have a space delimited text file but I only want to change the first space to a tab and keep the rest of the spaces intact. How do I go about doing that? Thanks! (3 Replies)
Discussion started by: evelibertine
3 Replies

4. Shell Programming and Scripting

Stripping out more than a space from a line, but keep single space.

Hi all, Is there a way to perform the above, I am trying to strip out more than one space from a line, but keep the single space. See below output example. My Name is test test2 test3 test4 test5 My Name is test test2 test3 test4 test5 Please note that the lines would contain... (7 Replies)
Discussion started by: eo29
7 Replies

5. Shell Programming and Scripting

Merging files into a single tab delimited file with a space separating

I have a folder that contains say 50 files in a sequential order: cdf_1.txt cdf_2.txt cdf_3.txt cdf_3.txt . . . cdf_50.txt. I need to merge these files in the same order into a single tab delimited file. I used the following shell script: for x in {1..50}; do cat cdf_${x}.txt >>... (3 Replies)
Discussion started by: Lucky Ali
3 Replies

6. Shell Programming and Scripting

Converting 2 or more spaces to a single tab

I'm new to bash and want to know a simple sed, awk, or grep script that will find all instances of 2 or more spaces and convert them to a single tab. Thanks for the help in advance. (1 Reply)
Discussion started by: jkandel
1 Replies

7. Shell Programming and Scripting

How to add 'n' of tab char?

Hi All, I need to add 'n' no. of tab char (\t) in a file thro' a script. Say for example if I give 5 as input then my script should give the all the lines with 5tabs. Input File : ####### 12323234 56465456 asdfdf456 dfgdf4564 So my Output File should look like:... (2 Replies)
Discussion started by: askumarece
2 Replies

8. Shell Programming and Scripting

need help in tab space !

i have a commad that display the total each directory size in KB.Below the commad and o/p: ls -ltr | grep ^d | awk '{print $9}' | xargs du -sk output: what i want is the proper tab space b/w value and dir.? how to get that. thanks in advance (10 Replies)
Discussion started by: ali560045
10 Replies

9. UNIX for Dummies Questions & Answers

how2 get single char from keyboard w/o enter

I am writing a bash shell menu and would like to get a char immediately after a key is pressed. This script does not work but should give you an idea of what I am trying to do.... Thanks for the help #! /bin/bash ANSWER="" echo -en "Choose item...\n" until do $ANSWER = $STDIN ... (2 Replies)
Discussion started by: jwzumwalt
2 Replies

10. Programming

Adding a single char to a char pointer.

Hello, I'm trying to write a method which will return the extension of a file given the file's name, e.g. test.txt should return txt. I'm using C so am limited to char pointers and arrays. Here is the code as I have it: char* getext(char *file) { char *extension; int i, j;... (5 Replies)
Discussion started by: pallak7
5 Replies
Login or Register to Ask a Question