Script to divide/expand first digit to show some numbers
Hello to everyone,
I have this complex problem and I don't how to do it. I'm not sure if awk could be a good choice to do it or could be easiest in bash or perl.
A kind of introduction would be:
- I have a digit, lets say 3.
- I can expand/spread out the digit 3 to cover all possible numbers that begin with 3 representing it with 2 digits and divide it in
10 parts like this:
30, 31, 32, 33, 34, 35, 36, 37, 38, 39. These 10 series are 3X, where X=0-9 and cover all values that begin with 3.
Well, what I really need is:
If have the digit 3 that covers all possible values that begin with 3 and I have some given numbers (one or more) that begin
with the same digit(in this example the digit is 3). I need to spread out the digit 3 up to the number of digits needed depending the
number of digits of the given numbers. Then add the text "GivenNum" once the 3 has been divided to show the given numbers.
Example:
Lets say that initial digit is 3 and given numbers are only two (304 and 3357):
Initial digit 3:
Numbers to show: 304, 3357
The output I'm looking for would be:
* As you can see for the first number 304, is needed to expand the series that begin with 3 up to 3 digits, since 304 has 3 digits.
* For the second number 3357, is needed to expand the series that begin with 3 up to 4 digits, since 3357 has 4 digits
* The series 31, 32, 34, 35, 36, 37, 38, 39 remain only represented up to 2 digits since the given numbers are not within of them.
i need to divide this count by 2, what variable can i use in my script?
26 hcscprod_cpus_totals /2 = 13
13 hcncprod_cpus_totals /2= 6.5
541 ktazp_cpus_totals /2= 270.5
346 ktazd_cpus_totals /2=173
110 ktazi_cpus_totals /2=55
10 ktazq_cpus_totals /2=5 (2 Replies)
Folks,
Is there a simple way to replace one digit by two digit using sed.
Example,
mydigit1918_2006_8_8_lag1.csv should be
mydigit1918_2006_08_08_lag01.csv.
I tried this way, but doesn't work.
echo mydigit1989_2006_8_8_lag1.csv|sed 's/]/0]/'
Thank you, (5 Replies)
divide input values into specified number (-100 or -200) according to the key (a1 or a2 ....)
For ex: if we give -100 in the command line it would create 100 number intervals (1-100, 100-200, 200-300) untill it covers the value 300 in a1.
Note: It should work the same even with huge numbers... (3 Replies)
Hi All,
I am stuck with this problem.
I have some 100000 (.dat) 1.dat, 2.dat,3.dat etc until 100000.dat files which look like this:
1.dat
1
2
3
4
0.99
4.54
All my files 1.dat until 100000.dat look the same but with different numbers.
I have to first add all the numbers in each... (1 Reply)
Hi Unix Gurus,
I have a requirement to generate positive random 16 and 13 digit numbers.
Here is the script I have so far.....
number=$RANDOM$RANDOM$RANDOM$RANDOM;
let "number %= 10000000000000";
echo $number
But sometimes it is generating negative numbers and also 15 digit... (8 Replies)
Hi,
I've been working on a few scripts and have been getting great info.
How, would I include in the below script, how I would let a user know that if they divide a SECOND number by zero, that they would get a divide by zero error? What's the easiest way of working this?
Cordially,
joe.
... (1 Reply)
Hello, I have an assignment that requires us to use sed only. The first part of the assignment says to use a sed script to print only the even lines, but if it is print, the number of that lines needs to be printed before the text.
ex:
2
line 2 text
4
line 4 text
6
line 6 text
... (3 Replies)