Allign the output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Allign the output
# 1  
Old 09-02-2010
Allign the output

Hi
I have an SQL which returns me the o/p as below in an unformatted manner
Code:
Table     Size            No. 
=============================================
DEF        22                 2
PAF   3                 1
99D        12                 1
USERS        6                 1
04D     4                    1

I would like to have it alligned as below . Please advice.
Code:
Tablespace      Size            No. 
============================================
DEF            22                 2
PAF            3                  1
99D            12                 1
USERS          6                  1
04D            15                 1

Thanks.
# 2  
Old 09-02-2010
Try this:
Code:
awk '$1=$1' OFS="\t\t" file > newfile

# 3  
Old 09-02-2010
Or pipe it through this for example..
Code:
awk '{printf("%-15s%6s%15s\n",$1,$2,$3)}'

# 4  
Old 09-02-2010
Hi.

Thanks..
But this gives me the below error
Code:
awk '$1=$1' OFS="\t\t" m.log > newm.log
awk: syntax error near line 1
awk: bailing out near line 1



---------- Post updated at 05:29 PM ---------- Previous update was at 05:27 PM ----------

Hey Scrutinizer.

Thanks. This did work. thankyou!!

Last edited by bakunin; 09-02-2010 at 09:51 AM.. Reason: corrected the tags for you
# 5  
Old 09-02-2010
Quote:
Originally Posted by jjoy
Hi.

Thanks..
But this gives me the below error
[code]
awk '$1=$1' OFS="\t\t" m.log > newm.log
awk: syntax error near line 1
awk: bailing out near line 1
Use nawk or /usr/xpg4/bin/awk on Solaris.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Allign the text result of a for/next cicle

Dear community, probably is quite easy, but I'm scratching my head to find a solution on Red Hat bash. What I have to do is to allign the result of a for/next cicle, something like: $ printf("%-5s %05x %5d\n", $next, $Server, $Client) -sh: syntax error near unexpected token `"%-5s %05x... (4 Replies)
Discussion started by: Lord Spectre
4 Replies

2. Red Hat

Command understanding the output file destination in case of standard output!!!!!

I ran the following command. cat abc.c > abc.c I got message the following message from command cat: cat: abc.c : input file is same as the output file How the command came to know of the destination file name as the command is sending output to standard file. (3 Replies)
Discussion started by: ravisingh
3 Replies

3. Shell Programming and Scripting

Displaying log file pattern output in tabular form output

Hi All, I have result log file which looks like this (below): from the content need to consolidate the result and put it in tabular form 1). Intercomponents Checking Passed: All Server are passed. ====================================================================== 2). OS version Checking... (9 Replies)
Discussion started by: Optimus81
9 Replies

4. Shell Programming and Scripting

How to allign output data in UNIX that is separated with a pipe "|" symbol ?

Experts , In the given output of the log file, the 2nd field that is separated by "|" pipe is not aligned well due to the uneven data length, I would like it to align the 2nd column with 37 length (that is disturbed in the output) including the pipe . The two pepe "|" would be in a aligned way... (2 Replies)
Discussion started by: rveri
2 Replies

5. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

6. Shell Programming and Scripting

Awk script to run a sql and print the output to an output file

Hi All, I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file. Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies

7. Shell Programming and Scripting

Allign text html

Hi All How do I allign these lines html,thank you <span class="time"><strong> 06:00 </strong></span> <div class="cDesc" style="display: none"> TEXTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT </div> <div class="cTitle" style="display: none"> ... (3 Replies)
Discussion started by: Novice-
3 Replies

8. Shell Programming and Scripting

awk: round output or delimit output of arithmatic string

I have a file with the following content. > cat /tmp/internetusage.txt 6709.296322 30000 2/7/2010 0.00I am using the following awk command to calculate a percentage from field 1 and 2 from the file. awk '{ print $1/$2*100 }' /tmp/internetusage.txt This outputs the value "22.3643" as a... (1 Reply)
Discussion started by: jelloir
1 Replies

9. Shell Programming and Scripting

top output for six processes with the same name, output changed from column to row

Hi, I have a system under test, and I use a script that does a ps. The output, is in the following format, it's basically the timestamp, followed by the rss and vsize. 09:03:57 68404 183656 68312 181944 69860 217360 67536 182564 69072 183172 69032 199276 09:04:27 68752 183292 70000 189020... (5 Replies)
Discussion started by: Bloke
5 Replies

10. Shell Programming and Scripting

how to make a line BLINKING in output and also how to increase font size in output

how to make a line BLINKING in output and also how to increase font size in output suppose in run a.sh script inside echo "hello world " i want that this should blink in the output and also the font size of hello world should be big .. could you please help me out in this (3 Replies)
Discussion started by: mail2sant
3 Replies
Login or Register to Ask a Question