Output allignment


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Output allignment
# 1  
Old 07-14-2010
Output allignment

Hi Guys,

I hope you are doing good out there.

I am facing some issues in the alligment of the output of a shell script.

Below is the statement which is formatting the output:
Code:
echo  $File | awk -F '[ /]' '{print $13,$15="\t"$16,$4="",$5,$6,$7}'

and its output is
Code:
Domain           Log file                                           Time last updated
ICCIR2TEST16    BPOrderExecutionManagement-Gemini-BPOrderExecutionManagement-Gemini.log  Jul 14 10:59
ICCIR2TEST16    ContactChannelManagement-SVAP-ContactChannelManagement-SVAP.log  Jul 14 10:42
ICCIR2TEST16    DataIntegration-Misc-DataIntegration-Misc.log  Jul 14 10:33
ICCIRSTDEV03    CustomerContactManagement-CRM6-CustomerContactManagement-CRM6.log  Jul 14 10:58
ICCIRSTDEV03    CustomerPersonalInformationManagement-CRM6-CustomerPersonalInformationManagement-CRM6.log  Jul 14 10:55
ICCIRSTDEV03    TIL_SCM_CRM6-TIL_SCM_CRM6.log  Jul 14 12:05

As you can see the last coloumn is not alligned properly. This is due to invariable string size of the files.

I tried lots of tricks but no luck.

Can you please let me know the way to properly allign the output?

Any help would be highly appereciated.

Thanks,
Chandan

Last edited by singh.chandan18; 07-14-2010 at 09:43 AM.. Reason: Changing the title
# 2  
Old 07-14-2010
use format specifiers %s with width: %30s.

I made up numbers because I don't know what your data looks like. When you need alignment always pick a width that is at least as wide or wider the field can ever be.

Code:
awk -F '[ /]' '{printf (%30s% %20s\t%30s %5s= %10s %10s %10s\n",$13,$15,$16,$4,$5,$6,$7) }'  $File

This User Gave Thanks to jim mcnamara For This Post:
# 3  
Old 07-15-2010
Thanks for the help Jim,

Now, the output is alligned properly after making the changes suggested by you. Please see below;

Code:
 Domain           Log file                                                                                 Time last updated
ICCIR2Test11     CustomerPersonalInformationManagement-CRM6-1-Process_Archive.log                            Jul 15 07:53
ICCIR2Test13     Top-UpTransactionManagement-PAS-Top-UpTransactionManagement-PAS.log                         Jul 15 07:31
ICCIRSTDEV03     CustomerContractManagement-Gemini-1-CustomerContractManagement-Gemini.log                   Jul 15 08:40
ICCIRSTDEV03     Top-UpTransactionManagement-PAS-2-Top-UpTransactionManagement-PAS.log                       Jul 15 07:31
ICCIRSTDEV03     WarehouseManagement-OOM-WarehouseManagement-OOM.log                                         Jul 15 07:31

Thanks once again for your help.

Chandan
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Allignment input file

Guys, I have a requirement as below 36%/ 55%/var 82%/tmp 74%/opt now i want the output to be --------------------------------- Disk% Mount --------------------------------- 36% / 55% var 82% tmp 74% opt ---------------------------------------- I have used... (3 Replies)
Discussion started by: AraR87
3 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

awk - script help: column to row format of data allignment?

Experts Good day, I have the following data, file1 BRAAGRP1 A2X B2X C2X D2X BRBGRP12 A3X B3X Z10 D09 BRC1GRP2 LO01 (4 Replies)
Discussion started by: rveri
4 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

Text allignment using PERL

Hi Friends, For daily reports i make perl script like below. @dirlist = `cat out.txt |cut -d "|" -f1 >create.txt`; @dirlist1 = `cat out.txt|wc -l *e* >create2.txt`; open FILE, ">OUTPUT.txt"; @command = `cat out.txt |cut -d "|" -f1`; print FILE map{$_-2 ."\n"}@command; @dirlist2 =... (1 Reply)
Discussion started by: adaleru
1 Replies

8. Shell Programming and Scripting

linux 'paste' allignment problem

Hi Everyone, # cat 1 #!/usr/bin/perl print "c\tc\t\n"; # cat 2 #!/usr/bin/perl print "b\tb\t\n"; print "b\tb\t\n"; print "b\tb\t\n"; # perl 1 > 11 # perl 2 > 22 # cat 11 c c # cat 22 b b b b b b # paste 11 22 (5 Replies)
Discussion started by: jimmy_y
5 Replies

9. Shell Programming and Scripting

Allignment

Hi All, I want to shift the last and second last line to 8 spaces in the right inside a file. please can somebody suggest a script for the same. Thanks and Best Regards, Shazin (22 Replies)
Discussion started by: Shazin
22 Replies

10. Shell Programming and Scripting

Allignment of lines in a file

Hi All, I am using the below scrit to insert lines in a file: #!/bin/ksh # To delete the last line if it contains the pattern Redirect permanent / Virgin Atlantic Airways - Popup echo "Enter the URL that should point to the particular microsite" read url # To delete the last line if it... (2 Replies)
Discussion started by: Shazin
2 Replies
Login or Register to Ask a Question

Featured Tech Videos