![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Output formating | jaydeep_sadaria | Shell Programming and Scripting | 1 | 04-10-2008 09:39 AM |
| formating output | Krrishv | Shell Programming and Scripting | 20 | 02-02-2007 06:39 AM |
| formating date | ragha81 | Shell Programming and Scripting | 2 | 01-05-2007 08:20 AM |
| How to concatenate two strings or several strings into one string in B-shell? | fontana | Shell Programming and Scripting | 2 | 08-26-2005 08:58 AM |
| Disk formating | DPAI | UNIX for Dummies Questions & Answers | 1 | 11-28-2001 05:06 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#8
|
||||
|
||||
|
Since you were using expr, I assumed that you were using sh which cannot do arithmetic. ksh is a great shell, but you're not using all of its features yet.
With ksh you can do: ((percent = 100 * used / avail)) which will work the same as ((percent = 100 * $used / $avail)) if "avail" and "used" both contain simple numbers. |
| Forum Sponsor | ||
|
|
|
#9
|
||||
|
||||
|
I'm not infront of a box I can test but it seems logical to me that printf or one of it's variants may have the thousands comma separator functionallity Neil was looking for. If anyone knows for sure, post back otherwise I will try to figure it out tomorrow if I have time.
|
|
#10
|
||||
|
||||
|
Quote:
If that is right, we can extend the sed one-liner: sed -e :a -e 's/^\([^.]*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta' This countinues to handle leading minus, plus, and dollar signs. In the accounting world, I've seen an odd convention of putting numbers in parentheses. That also works. |
||||
| Google The UNIX and Linux Forums |