Sponsored Content
Full Discussion: echo + bc + format
Top Forums Shell Programming and Scripting echo + bc + format Post 302322279 by radoulov on Wednesday 3rd of June 2009 08:48:02 AM
Old 06-03-2009
With recent versions of bash:

Code:
$ unset c
$ printf -vc %05d $((5*5))
$ echo $c
00025

With older versions:

Code:
$ unset c
$ c=$(printf %05d $((5*5)))
$ echo $c
00025

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

To convert multi format file to a readable ascii format

Hi I have a file which has ascii , binary, binary decimal coded,decimal & hexadecimal data with lot of special characters (like öƒ.ƒ.„İİ¡Š·œƒ.„İİ¡Š· ) in it. I want to standardize the file into ASCII format & later use that as source . Can any one suggest a way a logic to convert such... (5 Replies)
Discussion started by: gaur.deepti
5 Replies

2. Shell Programming and Scripting

Difference between using "echo" builtin and /bin/echo

So in my shell i execute: { while true; do echo string; sleep 1; done } | read line This waits one second and returns. But { while true; do /bin/echo string; sleep 1; done } | read line continues to run, and doesn't stop until i kill it explicitly. I have tried this in bash as well as zsh,... (2 Replies)
Discussion started by: ulidtko
2 Replies

3. UNIX for Dummies Questions & Answers

How to correctly use an echo inside an echo?

Bit of a weird one i suppose, i want to use an echo inside an echo... For example... i have a script that i want to use to take users input and create another script. Inside this script it creates it also needs to use echos... echo "echo "hello"" >$file echo "echo "goodbye"" >$file ... (3 Replies)
Discussion started by: mokachoka
3 Replies

4. Shell Programming and Scripting

Retaining the Unix CSV format in Excel format while exporting

Hi All, I have created a Unix Shell script whch creates a *.csv file and export it to Excel. The problem i am facing is that Users wants one of the AMOUNT field in comma separted values. Example : if the Amount has the value as 3000000 User wants to be in 3,000,000 format. This Amount format... (2 Replies)
Discussion started by: rawat_me01
2 Replies

5. UNIX for Dummies Questions & Answers

Format output from "echo" command

Hi, I have written a BASH shell script that contains a lot of "echo" commands to notify the user about what's going on. The script generates a log file that contains a copy of what is seen in the terminal. The echo statements are generally verbose, and thus extend out for quite a ways on one... (2 Replies)
Discussion started by: msb65
2 Replies

6. Shell Programming and Scripting

With that logic this echoes "echo". Question about echo!

echo `echo ` doesn't echoes anything. And it's logic. But echo `echo `echo ` ` does echoes "echo". What's the logic of it? the `echo `echo ` inside of the whole (first) echo, echoes nothing, so the first echo have to echo nothing but echoes "echo" (too much echoing :P):o (2 Replies)
Discussion started by: hakermania
2 Replies

7. Shell Programming and Scripting

Column format using echo in aix

Hi Friends, I have the following values in echo "$csi_tas_id" echo "$platform" echo "$region" I want to display these values as shown below: CSI_TAS_ID | PLATFORM | REGION 123 | UNIX | SG 231 | AIX ... (1 Reply)
Discussion started by: dbashyam
1 Replies

8. Shell Programming and Scripting

perl module to convert xlsx format to xls format

Hi Folks, I have written a perl script that reads data from excel sheet(.xls) using Spreadsheet::ParseExcel module. But the problem is this module doesn't work for excel sheets with extension .xlsx. I have gone through Spreadsheet::XLSX module with which we can read from .xlsx file directly.... (1 Reply)
Discussion started by: giridhar276
1 Replies

9. Solaris

Grant unprivileged user rights to see the output of echo|format but not modify disks

anyone have any idea how do to this with auth_attr? I suspect if I grant him solaris.device.:RO::Device Allocation::help=DevAllocHeader.html that will work but I'm unsure. Just looking for a second opinion. (10 Replies)
Discussion started by: os2mac
10 Replies

10. Solaris

Drive Offline on echo | format

Hi just want to ask if anyone has encounter this error? bash-3.2# echo | format Searching for disks...Mar 28 14:03:31 server1 scsi: WARNING: /pci@340/pci@1/pci@0/pci@7/SUNW,qlc@0,1/fp@0,0/ssd@w5006016408607763,0 (ssd3): Mar 28 14:03:31 server1 drive offline Mar 28 14:03:31 server1 scsi:... (1 Reply)
Discussion started by: gob23g
1 Replies
NUMFMT_SET_ATTRIBUTE(3) 						 1						   NUMFMT_SET_ATTRIBUTE(3)

NumberFormatter::setAttribute - Set an attribute

	Object oriented style

SYNOPSIS
public bool NumberFormatter::setAttribute (int $attr, int $value) DESCRIPTION
Procedural style bool numfmt_set_attribute (NumberFormatter $fmt, int $attr, int $value) Set a numeric attribute associated with the formatter. An example of a numeric attribute is the number of integer digits the formatter will produce. PARAMETERS
o $fmt -NumberFormatter object. o $attr - Attribute specifier - one of the numeric attribute constants. o $value - The attribute value. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 numfmt_set_attribute(3) example <?php $fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL ); echo "Digits: ".numfmt_get_attribute($fmt, NumberFormatter::MAX_FRACTION_DIGITS)." "; echo numfmt_format($fmt, 1234567.891234567890000)." "; numfmt_set_attribute($fmt, NumberFormatter::MAX_FRACTION_DIGITS, 2); echo "Digits: ".numfmt_get_attribute($fmt, NumberFormatter::MAX_FRACTION_DIGITS)." "; echo numfmt_format($fmt, 1234567.891234567890000)." "; ?> Example #2 OO example <?php $fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL ); echo "Digits: ".$fmt->getAttribute(NumberFormatter::MAX_FRACTION_DIGITS)." "; echo $fmt->format(1234567.891234567890000)." "; $fmt->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 2); echo "Digits: ".$fmt->getAttribute(NumberFormatter::MAX_FRACTION_DIGITS)." "; echo $fmt->format(1234567.891234567890000)." "; ?> The above example will output: Digits: 3 1.234.567,891 Digits: 2 1.234.567,89 SEE ALSO
numfmt_get_error_code(3), numfmt_get_attribute(3), numfmt_set_text_attribute(3). PHP Documentation Group NUMFMT_SET_ATTRIBUTE(3)
All times are GMT -4. The time now is 03:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy