Creating 12 digit string value


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Creating 12 digit string value
# 15  
Old 09-27-2010
Quote:
Originally Posted by Franklin52
but our intention is also to use portable code here.
that's your intention, not mine Smilie
A lot of solutions posted here in unix.com are not portable. It all depends on what OP has and whether its stated as a requirement. If not, writing portable code here is the least of concerns (at least for me)
# 16  
Old 09-27-2010
Kurumi, the intention on this forum is to write portable code. It is not a necessity. But if your solution is not portable it is good practice to specify in what environment it would work. This is so that solutions on this forum can be of maximum use to everyone. For instance in the case of your example you could state that it is bash/ksh93 only. If it is POSIX compliant then there is no need to do that. IMO Franklin was simply stating that it was not a portable solution so that readers know this to be the case...

Last edited by Scrutinizer; 09-27-2010 at 10:14 AM..
This User Gave Thanks to Scrutinizer For This Post:
# 17  
Old 09-27-2010
MySQL

Code:
# a=1234;let x=12-`echo $a| fold -w1 | sed -n '$='`;while [ $((x -= 1 )) -gt -1 ] ; do a=${a}1 ; done ; echo "New value -> $a"
New value -> 123411111111

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash: Getting first digit of a string

If i'm given a string like "abc-def-1.2.3", how would I return "1"? I'm new to scripting and got stumped on this problem. Thanks in advance! (7 Replies)
Discussion started by: atsim
7 Replies

2. Programming

Creating a string

I am trying to create a string from two strings using the following code and getting the following code and getting the warning In file included from ./prgms/raytrac.cc:62:0: baselib/clorfncs.hh: In function ‘void pr_hmisc(FILE*, int)’: baselib/clorfncs.hh:494:21: warning: deprecated... (2 Replies)
Discussion started by: kristinu
2 Replies

3. Shell Programming and Scripting

How to delete only the last digit in string

Hello, I would like to convert this string KBL3TEST1 into KBL3TEST How can i code this? Any help is appreciated regards, blashyou (6 Replies)
Discussion started by: blashyou
6 Replies

4. Shell Programming and Scripting

convert two digit in to single digit...

Hi Guys. My Input: ABCD 12 00 KL ABCD 12 08 DL ABCD 12 10 KK ABCD 12 04 LL ABCD 13 00 LP ABCD 13 1O LS Output: ABCD 12 0 KL ABCD 12 8 DL ABCD 12 10 KK ABCD 12 4 LL ABCD 13 0 LP (2 Replies)
Discussion started by: pareshkp
2 Replies

5. Shell Programming and Scripting

awk length of digit and print at most right digit

Have columns with digits and strings like: input.txt 3840 3841 3842 Dav Thun Tax Cahn 146; Dav. 3855 3853 3861 3862 Dav Thun Tax 2780 Karl VI., 3873 3872 3872 Dav Thun Tax 3894 3893 3897 3899 Dav Thun Tax 403; Thun 282. 3958 3959 3960 Dav Thun Tax 3972 3972 3972 3975 Dav Thun Tax... (8 Replies)
Discussion started by: sdf
8 Replies

6. Shell Programming and Scripting

Check whether a string begin with uppercase, lowercase or digit!

Hi every body! I wrote script on Fedora (bash shell) to check whether a tring enter from user console is start with a uppercase/lowercase letter or a digit. But with this script i have some problem when I enter from character from 'b' to 'z' --> result is uppercase. This code look like ok but i... (9 Replies)
Discussion started by: nguyendu0102
9 Replies

7. Shell Programming and Scripting

Single digit date to double digit date.

I have a var storing date var=`date` Now the date is returned as Mon Feb 2 00:25:48 PST 2009 Is there any way to check the date field alone ("2" in above case) and if its a single digit then add a prefix 0 to it and store the result in same variable "var" My intention in above case is... (3 Replies)
Discussion started by: villain41
3 Replies

8. Shell Programming and Scripting

Find first digit in string using expr index

I have looked for hours for an answer, so I have decided to request your guidance. I want to substract the first number (series of digits) contained in a string. This string is the output of another command. The substring (number) can be located at any position inside the string. I want to... (4 Replies)
Discussion started by: jcd
4 Replies

9. Shell Programming and Scripting

How to convert a 2 digit to 4 digit

Hi All, How can i convert a number 24 to 0024 In the same way how can i convert 123 to 0123? All this has to be done inside a script Thanks in advance JS (6 Replies)
Discussion started by: jisha
6 Replies

10. Shell Programming and Scripting

Replace one digit by two digit using sed

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)
Discussion started by: Jae
5 Replies
Login or Register to Ask a Question