In bash
will result in 000013 assigned to y. I'd not recommend maintaining your value this way, but use printf to format your filename with whatever inputs are necessary and converting the value at that time. Something like this:
or something similar.
If you are willing to use Ksh instead of bash, use the typeset command and each time the variable is used it will be presented with the format you desire:
This seems much cleaner to me, but it seems unsupported in bash.
Last edited by agama; 09-05-2010 at 09:35 PM..
Reason: clarification
Hi,
How to format a number in ksh. For example
x=RANDOM $$
I want x to be of 20 digits long, so if x = 12345 I want it to be left paded with 15 zeros.
Thanks. (2 Replies)
Hey,
I have a file which starts each line with 6 digits followed bya colon:
090607:The rest of the line
091207:Also some text
091207:Here's some more text
And I want to reformat them into:
06-09-07:The rest of the line
12-09-07:Also some text
12-09-07:Here's some more text
I... (3 Replies)
Hi All,
I want to convert Scientific number format into normal number format using unix script or using any command of unix.
e.g 1.55397e+09 into 1553970000
Thanks in advance
Kamal (1 Reply)
I try to read in a file and write out a new file with increased number at the end of each line. And I can set the initial value and increased constant from inputs.
input file:
text1
text2
text3
...
text100
if I set initial value is 10, and increased constant is 0.4
output file:
text1... (3 Replies)
I have a number coming into a php echo statement that looks like 0293 and i want to output it looking like 29.3 and for the life of me i cannot figure out how to do it with available php functions like number_format, sprintf, or printf.
Sample Data:
0293
0304
0282
0310
1324
2000
... (2 Replies)
I would like to change the format of an integer type number adding zeros to the left of it in a script in bash. For example
number=1
echo $number
00001
Thanks (3 Replies)
Hi,
using a shell script to get values from a CSV
eg:
12345.67,5678990.89,76232882.90
12345,5678990.89,76232882
Need the format of these numbers to change to
12,345.67:5,678,990.89:76,232,882.90
12,345:5678990.89:76232882
Using nawk on solaris, to parse these values, need the... (10 Replies)
Hello,
I need to format a number..like 12900 should be printed as 12,900
and 1209 as 1,209 and so on. (Just like we do in excel).
Can this be done in awk. any printf options we have?Please suggest me.
Thanks! (8 Replies)
I have a txt file as database. when i run my program what it does is it ask me for 3 name and stored in the file as
name1:name2:name3:1
when u enter 3 name it add those in file as above format and add 1 at the end. I what i want is if i enter same names again it changes that 1 to 2 and so... (3 Replies)
Hi Experts
I would like to ask if there is a way to validate if the variable passed is in this kind of sample format "06-10" or "10-01". It was really a challenge to me on how to start and echnically the "6-10" stands for "June 10" and "10-01" stands as "October 1", overall it needs to have ... (3 Replies)