Output alignment problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Output alignment problem
# 8  
Old 06-23-2010
Hi, Peter.

The majority of the script has to do with presenting the environment so that everyone knows which versions of programs were run, and what global settings are in effect.

The important line of code is simply:
Code:
align $FILE

Of course that assumes that you have obtained the perl script align and placed it in your path. If this seems too difficult, confusing, or too much work, then ignore it and try the other suggested solutions.

Best wishes ... cheers, drl
# 9  
Old 06-24-2010
Hi bartus11,

Thanks for your response and help.

First of all, I've tried to put your first script into the command line and put "\" when needed enter. However, there are some errors as shwon below.

Code:
# awk 'BEGIN{"awk '{$3=$3\" \"$4;$4=$5\" \"$6;$5=$7\" \"$8;$6=$9;\
> for (i=1;i<=NF-3;i++) if (max[i]<=length($i)) max[i]=length($i)}\
sh: Syntax error: `(' is not expected.

Could not figure out what is missing, hence unable to proceed.

Please kindly advice. Thanks



Regards,
Peter

---------- Post updated at 10:07 PM ---------- Previous update was at 08:23 PM ----------

Hi drl,

Thanks for your response.

I’ve downloaded and reviewed the align program from the website.

However, I would prefer to use a script that is easier to manage.

No offence. Thanks.



Regards,
Peter

---------- Post updated 06-24-10 at 12:40 AM ---------- Previous update was 06-23-10 at 10:07 PM ----------

Hi bartus11,

I’ve tested your second script, but after a few trying, I’m still unable to get it working.

Please see below for its error message.

Code:
# awk -f script.awk OUTPUT2
 awk: The string awk '{$3=$ cannot contain a newline character.
 The source line is 12.
 The error context is
                BEGIN{"awk '{$3=$3\" \"$4;$4=$5\" \"$6;$5=$7\" \"$8;$6=$9; >>>
 <<<
 syntax error The source line is 14.
 awk: The statement cannot be correctly parsed.
 The source line is 14.

Executed by using:
Code:
awk -f script.awk OUTPUT2

Seems like there is syntax error in the script.

Also, how would I be able to incorporate this script into my existing script rather than having another set of script?

Appreciate for any of your help and advice.

Thanks.


PS:
FYI, I’m using HPUX B.11.23 U ia64.


Regards,
Peter

---------- Post updated at 04:46 AM ---------- Previous update was at 01:47 AM ----------

Hi Gurus,

After much of trying, I manage to sort of getting the desired output.

Sample data:
Code:
/dev/vg00/lvol5 /home   0.12 GB 0.02 GB 0.10 GB 19%
/dev/vg00/misc  /misc   28.43 GB        4.92 GB 23.51 GB        17%
/dev/vg00/lvol6 /opt    8.25 GB 5.43 GB 2.82 GB 65%
/dev/vgsap/ora10264     /oracle/TES/102_64      9.89 GB 8.37 GB 1.52 GB 84%
/dev/vgsap/mirra        /oracle/TES/mirrlogA    0.48 GB 0.26 GB 0.21 GB 54%
/dev/vgsap/sapdata1     /oracle/TES/sapdata1    228.90 GB       89.47 GB        139.42 GB       39%

Script executed:
Code:
awk '{printf "%-22s %-23s %-1s %-8s %-1s %-8s  %-1s %-8s %-1s %-8s\n", $1, $2, $3, $4, $5, $6, $7, $8, $9, $10}' TEST_DATA

Output:
Code:
/dev/vg00/lvol5        /home                   0.12 GB       0.02 GB        0.10 GB       19%
/dev/vg00/misc         /misc                   28.43 GB       4.92 GB        23.51 GB       17%
/dev/vg00/lvol6        /opt                    8.25 GB       5.43 GB        2.82 GB       65%
/dev/vgsap/ora10264    /oracle/TES/102_64      9.89 GB       8.37 GB        1.52 GB       84%
/dev/vgsap/mirra       /oracle/TES/mirrlogA    0.48 GB       0.26 GB        0.21 GB       54%
/dev/vgsap/sapdata1    /oracle/TES/sapdata1    228.90 GB       89.47 GB        139.42 GB       39%

As shown above, the alignment is almost there, but there are still some issue from 4th column onwards.

Anybody can help and advice on how to solve this issue?

Thanks a lot.


Regards,
Peter

Last edited by superHonda123; 06-24-2010 at 07:01 AM.. Reason: remove unnecessary information
# 10  
Old 06-24-2010
How about this as an example:
Code:
awk '{printf "%-24s %-24s %6.2f %-3s %6.2f %-3s %6.2f %-3s  %4s\n", $1, $2, $3, $4, $5, $6, $7, $8, $9}' infile

Code:
/dev/vg00/lvol5          /home                      0.12 GB    0.02 GB    0.10 GB    19%
/dev/vg00/misc           /misc                     28.43 GB    4.92 GB   23.51 GB    17%
/dev/vg00/lvol6          /opt                       8.25 GB    5.43 GB    2.82 GB    65%
/dev/vgsap/ora10264      /oracle/TES/102_64         9.89 GB    8.37 GB    1.52 GB    84%
/dev/vgsap/mirra         /oracle/TES/mirrlogA       0.48 GB    0.26 GB    0.21 GB    54%
/dev/vgsap/sapdata1      /oracle/TES/sapdata1     228.90 GB   89.47 GB  139.42 GB    39%

This User Gave Thanks to Scrutinizer For This Post:
# 11  
Old 06-24-2010
Hi Scrutinizer,

Thanks a lot for the magic, it works perfectly. GREAT. Smilie



Regards,
Peter
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Coloring cli output, screws up 'alignment'

Heyas I'm trying to add color 'support' to my TUI. It works, but behaves weird. Code in question: (status.conf) R="\033" ; TUI_WORK="" TUI_DONE="" ; TUI_FAIL="" TUI_SKIP="" ; TUI_NEXT="" TUI_BACK="" ; TUI_CANC="" TUI_ON="" ; TUI_OFF="" TUI_INFO="" ; TUI_HELP="" The... (4 Replies)
Discussion started by: sea
4 Replies

2. Shell Programming and Scripting

Text qualifier issue causing data alignment problem

Hello Everyone, I have a csv file with text qualifier as "" and data similar to below: "1","abc","address1","US" "2","def","address1 "characters in double-quote" address2","IND" "3","ghi","address1","UK" In above example, for record 2, we have an issue as in column3 contains double... (2 Replies)
Discussion started by: AnkitSenghani
2 Replies

3. Shell Programming and Scripting

Shell script output alignment

Hi How can I alaign the output of a script. Exaplme my script has assigned values to two variables, VAR1 and VAR2 VAR1=This is RAJ working as a DB2 UDB DBA for VISA Corporation, Need your help in Shell scripting VAR2= This is RAM working as a ORACLE DEVELOPER for TARGET... (1 Reply)
Discussion started by: thriloka
1 Replies

4. Shell Programming and Scripting

Formatting output alignment

Hi Gurus, I've the following output from my scripting as shown below. 0.48 GB 0.29 GB 0.19 GB 60% 0.48 GB 0.29 GB 0.19 GB 60% 228.90 GB 89.47 GB 139.42 GB 39% 228.76 GB 72.37 GB 156.39 GB 31% Is it possible to format this output into a proper... (16 Replies)
Discussion started by: superHonda123
16 Replies

5. Shell Programming and Scripting

alignment

Hi, I am having a file with with format. however, for longer xml, the xml code has been truncated like this. F1 |###################### |String1 |<XML><REQ><MSGTYPE>DBDIRECT</MSGTYPE><SYNC>0</SYNC><CLIENT>C11</CLIENT>NAME=MYNAME|JOB=MYJOB| | ... (3 Replies)
Discussion started by: shellwell
3 Replies

6. Shell Programming and Scripting

Text Alignment Problem

Dear Friends, I've one file "sample.log" with the below comma separated lines: BOND_FORWARD,0 succeeded,0 failed. EQUITY_FORWARD,0 succeeded,0 failed. FRA,12 succeeded,0 failed. OPTION_BAR,16 succeeded,0 failed. OPTION_VAN,76 succeeded,0 failed. RENTOPT_CAP_FLOOR,4775 succeeded,0 failed.... (2 Replies)
Discussion started by: ganapati
2 Replies

7. Programming

how to round up a memory address(memory alignment problem)

Hi, I try to marshal a unsigned int and a char * into a buffer, and then unmarshal them later to get them out. I need to put the char * in the front and unsigned int at the end of the buffer. However, my system always give me "BUS ERROR". I am using Sun Sparcs Sloris 2.10. My code to marshal... (6 Replies)
Discussion started by: nj302
6 Replies

8. Solaris

Memory Alignment Problem on Sun Sparcs

Hi, I try to marshal a unsigned int and a char * into a buffer, and then unmarshal them later to get them out. I need to put the char * in the front and unsigned int at the end of the buffer. However, my system always give me "BUS ERROR". I am using Sun Sparcs Sloris 2.10. My code to marshal the... (1 Reply)
Discussion started by: nj302
1 Replies

9. Shell Programming and Scripting

output display alignment !!

Hi I'm trying to display the output of my script in a friendly viewable format. it's something like this.. i have this while loop... in which i get some records from a file where fields are delimitered with a pipe. so i'm extacting each field and replacing the pipe with a \t, tab !!.. cat... (7 Replies)
Discussion started by: rosh0623
7 Replies

10. UNIX for Dummies Questions & Answers

ls command alignment problem

With older Linux servers, the command: ls -al would output text that would have the filenames all lined up in the same column (the owner and group names were truncated to produce a uniform right column). In newer distros (i.e. RHEL 3), the command will push the right column out when owners... (0 Replies)
Discussion started by: robf
0 Replies
Login or Register to Ask a Question