Awk reporting. Format the output with left justification for every feild


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Awk reporting. Format the output with left justification for every feild
# 1  
Old 11-11-2008
Awk reporting. Format the output with left justification for every feild

Fallowing is the input file that is pipe seperated.
is it possible to generated the report that is alligned left justifed as that of sample output.
I apprecitae your help on this.

InputFile (temp.txt):
Code:
108005555|001|christina.lipski||Submitter Signature|2005/05/09-19:16:19:021|2005/05/10-15:52:36:112| eSCR 10744 attachment in REF file
108005555|001|james.m.thompson|Unable to Complete (See Comments)|Initial Change Request Assessment|2005/05/09-19:16:21:794|2005/05/10-15:00:48:486|1 Christina Lipski
~In the body of the change request I cut and pasted Jim Lopez's comments. According to him, the inductance limit is already complete and the eSCR should have been describing a different request to change the process. Read the comment. The eSCR should probably be rejected and re-issued with the proper description. 
108005555|001|james.m.thompson||Submitter Signature|2005/05/10-15:00:25:440|2005/05/10-15:00:54:659|0 Mike,
~Do you agree that this eSCR should be reissued by the supplier AND that you should be the change owner?
108005555|001|super user|OK - See Comments|Read the comments and correct me if I'm wrong.|2005/05/10-15:00:27:109|2005/05/10-15:00:53:687| Auto-signoff for Advisor Participant "james.l.lopez" to remove from inbox.
108005555|001|super user|OK - See Comments|Read the comments and correct me if I'm wrong.|2005/05/10-15:00:27:187|2005/05/10-15:00:53:964| Auto-signoff for Advisor Participant "michael.s.thompson" to remove from inbox.
108005555|001|christina.lipski|Complete (See Comments)|Perform additional work on CR|2005/05/10-15:01:00:066|2005/05/10-15:20:26:144| CR cannot be completed. Please reject. 
108005555|001|james.m.thompson|Unable to Complete (See Comments)|Initial Change Request Assessment|2005/05/10-15:20:28:870|2005/05/10-15:52:11:597| eSCR that initiated this change request had wrong information. eSCR is rejected.

Output File Should look like
Code:
==================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
USER                     ACTION TAKEN    ASSIGNMENT     TIMESTAMP IN    SIGNOFF DATE             COMMENTS  
==================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
christina.lipski      Submitter Signature    2005/05/09-19:16:19:021   2005/05/10-15:52:36:112    eSCR 10744 attachment in REF file
james.m.thompson          Unable to Complete (See Comments) Initial Change Request Assessment  2005/05/09-19:16:21:794   2005/05/10-15:00:48:486   1 Christina Lipski~In the body of the change request I cut and pasted Jim Lopez's comments. According to him, the inductance limit is already complete and the eSCR should have been describing a different request to change the process. Read the comment. The eSCR should probably be rejected and re-issued with the proper description. 
james.m.thompson      Submitter Signature    2005/05/10-15:00:25:440   2005/05/10-15:00:54:659   0 Mike,~Do you agree that this eSCR should be reissued by the supplier AND that you should be the change owner?
super user                OK - See Comments   Read the comments and correct me if I'm wrong. 2005/05/10-15:00:27:109   2005/05/10-15:00:53:687    Auto-signoff for Advisor Participant "james.l.lopez" to remove from inbox.
super user                OK - See Comments   Read the comments and correct me if I'm wrong. 2005/05/10-15:00:27:187   2005/05/10-15:00:53:964    Auto-signoff for Advisor Participant "michael.s.thompson" to remove from inbox.
christina.lipski          Complete (See Comments)  Perform additional work on CR   2005/05/10-15:01:00:066   2005/05/10-15:20:26:144    CR cannot be completed. Please reject. 
james.m.thompson          Unable to Complete (See Comments) Initial Change Request Assessment  2005/05/10-15:20:28:870   2005/05/10-15:52:11:597    eSCR that initiated this change request had wrong information. eSCR is rejected.

I have tried the fallowing AWK script. did not help me with the correct format.

Code:
awk -F"|" '
BEGIN {
print "==========================================================================================================================================================="
printf "%-25s%-25s%-10s%-25s%-25s%-10s\n","USER","ACTION TAKEN","ASSIGNMENT","TIMESTAMP IN","SIGNOFF DATE","COMMENTS"
print "===========================================================================================================================================================\n"
}
{
printf "%-25s %-25s %-10s %-25s %-25s %-10s\n",$3,$4,$5,$6,$7,$8
}
END {
print ""
}
'temp.txt

Edit: I took the liberty to edit your post to make it more readable. Please use [ code ] and [ /code ] tags and empty lines to form paragraphs and to make your code and logs etc. eye friendly, ty. Smilie

Last edited by zaxxon; 11-11-2008 at 08:06 AM.. Reason: Formatting and using code tags for readability
# 2  
Old 11-11-2008
Question

What was wrong with your code? How did it not provide what you were looking for?

By the way, how do you want to deal with fields where the text supplied is greater than the 20 or 25 columns you want to print it in? Do you want to only print the first characters and delete the rest?
# 3  
Old 11-11-2008
I would like to print out all the characters in all the feilds that are pipe seperated. output should be left justified.
# 4  
Old 11-11-2008
I have run the fallowing command against the input temp file attached.
awk -F"|" '
BEGIN {
print "=================================================================================================== ========================================================"
printf "%-25s%-25s%-10s%-25s%-25s%-10s\n","USER","ACTION TAKEN","ASSIGNMENT","TIMESTAMP IN","SIGNOFF DATE","COMMENTS"
print "=================================================================================================== ========================================================\n"
}
{
printf "%-25s %-25s %-10s %-25s %-25s %-10s\n",$3,$4,$5,$6,$7,$8
}
END {
print ""
}
'temp.txt

However i did get the output the way i want.

Please see the Report.TXT attached. (output file)

Last edited by ainuddin; 11-11-2008 at 10:22 AM.. Reason: Missed Attachments
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to maintain in- and output format with awk

Hi All, I have a data file (myfile.txt) as below: - A H C - A HHH F - AAA HH I The importan point is that the width between the columns are not fixed and the column seperator is space. I wish to change the value of 4th column using awk only when $3 = HH. I can... (4 Replies)
Discussion started by: angshuman
4 Replies

2. Shell Programming and Scripting

Format output using awk

Hello all , need help with this ... Input File DEV % POOL 0CB4 FBA 2211300 81792 4 IE RAID-5(3+1) R5_EFD100_1 - - 1805376 82 IF RAID-1 M2_FC300_1 - ... (4 Replies)
Discussion started by: greycells
4 Replies

3. UNIX for Dummies Questions & Answers

after awk-> format output

hi i have a awk command with several querys.... awk 'FS="|""; print $4, $5, $6...etc.... $4 gives me the date 20120304 $5 is timestamp 101023 I want to format these in 2012.03.04 or 2012/03/04 10:10:23 but have no idea, if this is possible with format-parameters in the awk... (2 Replies)
Discussion started by: Jazzmatazz
2 Replies

4. Shell Programming and Scripting

awk to format an output

awk experts, I have in put file with time stamp followed by "," separated data. same patern continues. The output need time stamp in first columns and data total in 2nd columns. Input file T 9:15 d0,1,3,3 d1,2,1,1 d2,3,1,5 e1,1,1,1 T 9:30 d0,1,1,1 d1,2,3,2 d3,1,2,1... (10 Replies)
Discussion started by: arv_cds
10 Replies

5. Shell Programming and Scripting

awk - format output

Input file1 zone: BAU_SERVER1 C0:50:76:01:C6:20:00:12; 50:06:01:69:3B:20:14:8B; 50:06:01:60:3B:20:14:8B zone: BAU_SERVER2 C0:50:76:01:C6:20:00:08; 50:06:01:69:3B:20:14:8B; 50:06:01:60:3B:20:14:8B zone: ... (4 Replies)
Discussion started by: greycells
4 Replies

6. Shell Programming and Scripting

How can I change is output format by awk ?

Hello, Can you tell me how can I change this format by awk Input 0.2057422D-01 0.2463722D-01 -0.1068047D-02 Output 0.02057422 0.02463722 -0.001068047 Thanks wan (8 Replies)
Discussion started by: wanchem
8 Replies

7. Shell Programming and Scripting

scripting/awk help : awk sum output is not comming in regular format. Pls advise.

Hi Experts, I am adding a column of numbers with awk , however not getting correct output: # awk '{sum+=$1} END {print sum}' datafile 2.15291e+06 How can I getthe output like : 2152910 Thank you.. # awk '{sum+=$1} END {print sum}' datafile 2.15079e+06 (3 Replies)
Discussion started by: rveri
3 Replies

8. Shell Programming and Scripting

[need help] output format from awk

hi all, i have a problem with my nawk command output below is the description : nawk $12 == "00008001" { cnt++;cs_cd } END {for(cd in cs_cd) print cd, cs_cd } 2007020814.TDR output : 133 123 desire output: 133,123,.... please advices thank you so much (6 Replies)
Discussion started by: bucci
6 Replies

9. Shell Programming and Scripting

Output in a particular format using AWK

Hi All, I am trying to check if if column 5 is greater than 90. If greater it will print the term in column 6, else if all are within limit, then it will output "Size is within limit". I can't seem to do that with the below code. The output should only be 1 statement of "Size is within the... (4 Replies)
Discussion started by: Raynon
4 Replies

10. Shell Programming and Scripting

printing 3rd or 4th feild from last in awk.

Whats up fellas... hope someone can help me with the following... I am parsing an file that is space delimited, however, in the middle, there is an ugly "Account Name" feild that in itself has multiple varying spaces, and commas which throws off my script. The 1st 3 feilds I am able to obtain... (8 Replies)
Discussion started by: djsal
8 Replies
Login or Register to Ask a Question