How to Add Table with Header for Shell Output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to Add Table with Header for Shell Output
# 1  
Old 04-28-2011
How to Add Table with Header for Shell Output

I have a Script that generates 3 columns of the result. The line script is

Code:
/usr/xpg4/bin/awk -F' [<>]' '{print $1 /t  $2}' File_Name | awk -F'>' '{print $2}' | cut -d'<' -f1 | sort -rn | uniq -c

The output of the Command is :

Code:
Code.500       4             Input Error
Code.404       100         Expression Invalid, add substance to the value
Bla bla           bla          bla bla bla bla bla bla bla bla bla bla bla bla bla bla bl

But i Want to add Table & Header for the result ,.. something like this.

=======================================================
Error Code | Count | Error Text
=======================================================
Code.500 | 4 | Input Error
Code.404 | 100 | Expression Invalid, add substance to the value
Bla bla | bla | bla bla bla bla bla bla bla bla bla bla bla bla bla bla
========================================================
# 2  
Old 04-28-2011
if you can provide the input file, I can help to combine into one awk command.

here is the awk print command to print the header
Code:
awk 'BEGIN {print "=======================================================\nError Code | Count | Error Text\n=======================================================\n"}'

# 3  
Old 04-28-2011
So here i have attached the file for you. Have a look into that
# 4  
Old 04-28-2011
Code:
awk 'BEGIN {print "======================================================="
            print "Error Code | Count | Error Text"
            print "======================================================="}
/:/&&/^Error/ {print substr($1,1,9), substr($1,10,4),$2;next}
/^Error/ {print substr($1,1,9), substr($1,10,4),substr($1,14)}
END{print "========================================================"}
' FS=":" OFS="|"  Error.txt

=======================================================
Error Code | Count | Error Text
=======================================================
Error.500|  91| nvalid Token Number
Error.500|   6| Unidentifiable Error
Error.500|   2| Unable to determine  The error because of invalid response code!
Error.500|   7| Processor Decline
Error.500|  12| No Account
Error.500|  11| Lost/Stolen Token
Error.500|   1| Issuer Unavailable
Error.500|  42| Invalid Transaction Type
Error.500|   3| Invalid CCToken Number
Error.500|1522| Insufficient Token Account
Error.500| 438| Do Not Honor Token
Error.500|  11| Token is Expired
Error.500|  75| Token Restricted
Error.500|   8| Token Issuer wants Token returned
Error.500|  69| MMC Failure
Error.500|  18|  Security code validation failed. Unknown security code error!
Error.500|   8|  CC Negative File Match
========================================================

# 5  
Old 04-28-2011
From the script.. I need to ignore two components.

1st -> ^Error
2nd -> ' FS=":"

Primarily For Error

Because these two components are always dynamic . This keep changing. Sometimes we see INFO , DEBUG, in place of Error. So it should by generic .

Secondarily for FS

Most of the times we dont get FS to separate and place them into colum. So its better we remove that
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell output format like table

Hi, OS: Redhat 7.5 shell: Bash Wrote below script to login into oracle via shell script and trying to reset locked account..It works as expected. But I need specific output << EOF should go to target terminal not all out put running below script from ansible command line.. #!/bin/bash... (1 Reply)
Discussion started by: onenessboy
1 Replies

2. Shell Programming and Scripting

Convert shell script output txt file to html table

My concnern related to the post -Convert shell script output txt file to html table, in this how to print the heading as color. awk 'BEGIN{print "<table>"} {print "<tr>";for(i=1;i<=NF;i++)print "<td>" $i"</td>";print "</tr>"} END{print "</table>"}' <filename> (8 Replies)
Discussion started by: sarajobmai
8 Replies

3. Shell Programming and Scripting

Please help in populating output in table using shell scripting

Below is my code where i tried using table tag to print out put in table but its not working #!/bin/ksh #] && . ./.profile 2>/dev/null if test -f '.profile'; then . ./.profile; fi; #. .profile LOG_DIR=/app/rpx/jobs/scripts/just/logs sendEmail() { pzCType="$1";... (5 Replies)
Discussion started by: ankit.mca.aaidu
5 Replies

4. Shell Programming and Scripting

I want query output to send on mail using table tag and output should be in table

#! /bin/ksh #] && . ./.profile 2>/dev/null if test -f '.profile'; then . ./.profile; fi; #. .profile LOG_DIR=/app/rpx/jobs/scripts/just/logs sendEmail() { pzCType="$1"; pzTitle="$2"; pzMsg="$3"; pzFrom="$4"; pzTo="$5"; pzFiles="$6"; pzReplyTo="$7" ( ... (21 Replies)
Discussion started by: ankit.mca.aaidu
21 Replies

5. Shell Programming and Scripting

Need to Print output in table using shell script

#! /bin/ksh #] && . ./.profile 2>/dev/null if test -f '.profile'; then . ./.profile; fi; #. .profile LOG_DIR=/app/rpx/jobs/scripts/just/logs sendEmail() { pzCType="$1"; pzTitle="$2"; pzMsg="$3"; pzFrom="$4"; pzTo="$5"; pzFiles="$6"; pzReplyTo="$7" ( ... (4 Replies)
Discussion started by: ankit.mca.aaidu
4 Replies

6. Shell Programming and Scripting

[Solved] Shell script output in HTML or with table like results and mail

Hello, Currently i have a script which will disply the results in plain text format. I want to format the result in more readable format like Making bold headings and format with colors etc. Something like html and send that content as email. Please help me how i can do that. I am using... (10 Replies)
Discussion started by: joy lobo
10 Replies

7. Shell Programming and Scripting

shell, read table and write the value for each factor to output

Hey guyz, I have a table like this: 1 A=#;B=#;C=# 2 A=#;C=#;D=#;E=#;E=# 3 B=#;B=#;B=#;D=# # are just some numbers. I want to have the output like this: * 1 2 3 A # # NA B # NA # C # # NA D NA # # E NA # NA So basically, I wanna know in each of the rows in my input (which... (9 Replies)
Discussion started by: @man
9 Replies

8. Shell Programming and Scripting

Convert shell script output txt file to html table

Hi, I have script which generates the output as below: Jobname Date Time Status abc 12/9/11 17:00 Completed xyz 13/9/11 21:00 Running I have the output as a text file. I need to convert it into a HTML Table and sent it thru email ... (6 Replies)
Discussion started by: a12ka4
6 Replies

9. Shell Programming and Scripting

shell script output in HTML or with table like results

Hello, Currently i have a ksh script which will disply the results in plain text format. I want to format the result in more readable format like Making bold headings and format with colors etc. Something like html or excel format and send that content as email. Please help me how i can do... (2 Replies)
Discussion started by: kotasateesh
2 Replies
Login or Register to Ask a Question

Featured Tech Videos