Formatting Array Output


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Formatting Array Output
Prev   Next
# 1  
Old 07-09-2013
Formatting Array Output

Hello All,
Q1) I have the below code but when the email was sent out all lines are merged and coming out as a single line though my printf statement has newline "\n", How do i avoid that?
Q2) In my second IF statement when i introduced the backslash "\" for continuation of a line or command, i see the output coming out with tabspaces probably because of identation, how do i avoid those spaces?

Code:
#!/bin/ksh
if [ "${TOT_PRINCIPAL_BALANCE_DOLLARS}" -eq "${COMP_PRINCIPAL_BALANCE_DOLLARS}" ]
then
        ((i+=1))
        ARR[$i]="Principal Balance Dollars For Uninum($UNINUM): ${TOT_PRINCIPAL_BALANCE_DOLLARS} Doesn't Match With ${COMP_PRINCIPAL_BALANCE_DOLLARS}, Difference is: $((${TOT_PRINCIPAL_BALANCE_DOLLARS}-${COMP_PRINCIPAL_BALANCE_DOLLARS}))"
fi


if [ "${TOT_PD_RATING_VALUES}" -eq "${COMP_PD_RATING_VALUES}" ]
then
        ((i+=1))
        ARR[$i]="PD Rating Values For Uninum($UNINUM): ${TOT_PD_RATING_VALUES} Doesn't Match With ${COMP_PD_RATING_VALUES}, \
                        Difference is: $((${TOT_PD_RATING_VALUES}-${COMP_PD_RATING_VALUES}))"
fi

if [ ${#ARR[*]} -gt 0 ]
then
        logit "Array is not empty"
        printf "%s\n" "${ARR[@]}" | mailx -s "ALERT: Hash Total Comparision Inconsistencies" "${EMAIL_LIST}"
else
        logit "Array is empty, Email Will Not Be Sent Out As The Hash Total Comparisions Is Successfull"
fi

Output For Question1:
Code:
Loan Row Count For Uninum(710119): 1311 Doesn't Match With 1312, Difference is: -1 Book Value Dollars For Uninum(610000): 11130853744.9 Doesn't Match With 11130853744.96, Difference is: -0.0599999995902180672 Principal Balance Dollars For Uninum(710056): 183498285 Doesn't Match With 183498286.85, Difference is: -1.85000000000582077 PD Rating Values For Uninum(710122): 12500 Doesn't Match With 12498, Difference is: 2

Output For Question2:
Code:
[Tue Jul  9 09:56:07 EDT 2013] - Loan Row Count For Uninum(710119): 1311 Doesn't Match With 1312,                               Difference is: -1
[Tue Jul  9 09:56:07 EDT 2013] - Book Value Dollars For Uninum(710119): 519090514.68 Matches With 519090514.68
[Tue Jul  9 09:56:07 EDT 2013] - Principal Balance Dollars For Uninum(710119): 513703522.97 Matches With 513703522.97
[Tue Jul  9 09:56:07 EDT 2013] - PD Rating Values For Uninum(710119): 8903 Matches With 8903
[Tue Jul  9 09:56:07 EDT 2013] - Loan Row Count For Uninum(610000): 4026 Matches With 4026
[Tue Jul  9 09:56:07 EDT 2013] - Book Value Dollars For Uninum(610000): 11130853744.9 Doesn't Match With 11130853744.96,                        Difference is: -0.0599999995902180672
[Tue Jul  9 09:56:07 EDT 2013] - Principal Balance Dollars For Uninum(610000): 11092468530.32 Matches With 11092468530.32
[Tue Jul  9 09:56:07 EDT 2013] - PD Rating Values For Uninum(610000): 26749 Matches With 26749
[Tue Jul  9 09:56:07 EDT 2013] - Loan Row Count For Uninum(710056): 635 Matches With 635

please help thank you.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl array formatting

Experts, I'm having problems with a portion of my perl script. I have a perl array that contains the following: Port1,circuit3,2;4 Port2,circuit1,9;6 Port3,circuit2,12;5 Port4,circuit4,11;10;3 Port5,circuit7,8;7;1 I'm trying to produce the following output: (3 Replies)
Discussion started by: timj123
3 Replies

2. AIX

Help Formatting Output

I am using FORTRAN 90 on AIX 5.3 and need to output my data to a tab-delimited file. It must have actual tabs, and I cannot figure out a way to make it work. The resulting file will be imported into another application (quickbooks) as an .iif file....for some reason, it needs the tabs; spaces do... (2 Replies)
Discussion started by: KathyB148
2 Replies

3. Filesystems, Disks and Memory

iostat output vs TPC output (array layer)

Hi Guys, I've been having some arguments with my colleagues about one thing. Always my thought was that as as far as disk performance is concern by looking at the output of the iostat command (AIX) you would be able to identify if you have a hot disk and then by moving some files out that disk... (3 Replies)
Discussion started by: arizah
3 Replies

4. Shell Programming and Scripting

Formatting of output

Hi Experts, I have to create a report for certain audit and my output looks as follows I m trying to format my output to look like Any inputs would be highly appreciated Thanks Syed (5 Replies)
Discussion started by: maverick_here
5 Replies

5. Shell Programming and Scripting

Output formatting

I have input file in this way John 1234 BASIC 26000 John 1234 ALLOWC 01550 John 1234 INCER 01700 John 1234 REL 20000 Debi 2345 BASIC 29000 Debi 2345 ALLOWC 01600 Debi 2345 INCR 01900 Debi 2345 REL ... (8 Replies)
Discussion started by: vakharia Mahesh
8 Replies

6. Shell Programming and Scripting

more help with formatting ls output...

Ok, for a fun project, my goal is to replicate the style of "catalog" on an old apple ] *A 002 SOMEAPPLESOFTFILE B 004 SOMEFILE T 006 SOMETEXT I 002 SOMEINTEGERFILE The first character is either " " or "*" depending on if the file is locked or not. Next is the filetype, so in... (1 Reply)
Discussion started by: patrick99e99
1 Replies

7. Shell Programming and Scripting

formatting the output

Is it possible to convert the attached file to the format mentioned. Here for a particular job the table name and the corresponding instance name from one test run "X" is compared with the table name and the instance name from the second test run "Y" for output rows,affected rows,applied... (1 Reply)
Discussion started by: ragavhere
1 Replies

8. Shell Programming and Scripting

Formatting Output

Hi I tried running the below awk 'BEGIN { printf ("%s %-51s %s %-7s %s",$var1,$var2,$var3,$var4,$var5)}' from the command prompt and it is not working. Getting the error awk: Field $() is not correct. The source line number is 1. Actually my requirement is to form a string based on... (6 Replies)
Discussion started by: dhanamurthy
6 Replies

9. Shell Programming and Scripting

Array Retrieval Formatting

I have a shell script (Solaris v8 ksh) loading an array from a flat file. An exaple of that flat file is below. It contains white-spaces, and carrage returns. When I try to load the first line as a variable, it (the variable) shows up as the first field not the first line. How do you arrange an... (9 Replies)
Discussion started by: gozer13
9 Replies

10. Shell Programming and Scripting

Formatting the output

Hi all, Have the following code(1) producing the results(2 & 3). Would like to know if there is a way to format the two reports created in a similar fashion. IE - The first is formatted nicely as a result of the echo "$xmpbdate $xavgs" >> $xmpbrpt However when I attempt to do the same on... (7 Replies)
Discussion started by: Cameron
7 Replies
Login or Register to Ask a Question