Formatting Array Output


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Formatting Array Output
# 8  
Old 07-09-2013
A quick-and-dirty way might be adding "<html><pre>" to the beginning and </pre></html>" to the end since Outlook ought to happily parse any html it finds anywhere. This may look weird in other email clients.

You can put printf in backticks like any other command to capture its output. STRING=$(printf whatever) Some versions have more convenient ways but this method should work most places.
# 9  
Old 07-09-2013
I don't understand what you want. Do you want the code that puts floating point values into your array to put them into the array with three decimal places? Or, do you want the code that prints the array of strings to go through the string before printing it, look for strings of digits with a decimal point and round (or truncate) those values to three decimal places before printing the array of strings? Should ".000" be added to the end of other strings of decimal digits
# 10  
Old 07-09-2013
Is there a way to set the scale for this
Code:
'$((${TOT_PRINCIPAL_BALANCE_DOLLARS}-${COMP_PRINCIPAL_BALANCE_DOLLARS}))'

while inserting an element into array instead of manipulating the printf statement.

Not required to have ".000" at the end of other strings of decimal digits, I need the output to be rounded off to 2 or 3 places after decimal.

---------- Post updated at 04:21 PM ---------- Previous update was at 04:03 PM ----------

I think got it not sure if there are loop holes and any better approach
Code:
ARR[$i]="Principal Balance Dollars For Uninum($UNINUM): '${TOT_PRINCIPAL_BALANCE_DOLLARS}' Doesn't Match With '${COMP_PRINCIPAL_BALANCE_DOLLARS}', 
Difference is: '`echo ${TOT_PRINCIPAL_BALANCE_DOLLARS}-${COMP_PRINCIPAL_BALANCE_DOLLARS} | bc `'"

# 11  
Old 07-09-2013
You cannot do floating point arithmetic in most shells, bc is a good option.
This User Gave Thanks to Corona688 For This Post:
 
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