I have a Script that generates 3 columns of the result. The line script is
/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.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
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
awk 'BEGIN {print "=======================================================\nError Code | Count | Error Text\n=======================================================\n"}'
So here i have attached the file for you. Have a look into that
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
========================================================
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