04-23-2008
if you would like the transformed value inside the same variable then you could use
one=1
one=`printf "%04i" $one`
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I found below script to check whether the variable is a digit in ksh.
############################
#!/bin/ksh
REPLY="3f"
if ]*\)'` != ${REPLY} && "${REPLY}" != "0" ]]
then
print "is digit\n"
else
print "not digit\n"
fi
############################
Although it works fine, but... (6 Replies)
Discussion started by: sleepy_11
6 Replies
2. Shell Programming and Scripting
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
3. Shell Programming and Scripting
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
4. Shell Programming and Scripting
I have string like
abcdefgh
i want to delete first two digit of the string. output should be
cdefgh
plz give me solution (3 Replies)
Discussion started by: Gopal_Engg
3 Replies
5. Programming
I have to write a c program which takes a 3 digit number n and calculates the value of (2^n)+1 and then determines the number is prime or not.
I have tried to first calculate the value of 2^n and then adding one to it and then apply the logic of prime number.
but the ultimate problem is that... (7 Replies)
Discussion started by: agrawal.prachi
7 Replies
6. Programming
Hi,
Does anybody know what the below means:
I have a program containing the following and am trying to understand what it does:
temp=$(echo $count2 | tr -cd )
Cheers
Paul
Please start using code tags (2 Replies)
Discussion started by: runnerpaul
2 Replies
7. Shell Programming and Scripting
Hi all,
Need your help here. I have a file with thousand of lines, as shown in example below
KDKJAA 98324
OIDSAJ 324
KJAJAK 100
KJKAJK 89
JOIJOI 21
JDKDJL 12
UOIUOD 10
UDUYDS 8
UIUHKK 6
I would like to grep using... (5 Replies)
Discussion started by: masterpiece
5 Replies
8. Shell Programming and Scripting
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
9. Shell Programming and Scripting
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
10. Shell Programming and Scripting
Thanks of your suggestions i was able to calculate the delta between some numbers in a column file with .
awk 'BEGIN{last=0}{delta=$1-last; last=$1; print $0" "delta}'
the file was like
499849120.00
500201312.00
500352416.00
500402784.00
500150944.00
499849120.00
500150944.00... (3 Replies)
Discussion started by: Board27
3 Replies
strxfrm(3) Library Functions Manual strxfrm(3)
NAME
strxfrm - Transforms string for collation in current locale
LIBRARY
Standard C Library (libc.so, libc.a)
SYNOPSIS
#include <string.h>
size_t strxfrm(
char *s1,
const char *s2,
size_t n);
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
strxfrm(): XPG4, XPG4-UNIX
Refer to the standards(5) reference page for more information about industry standards and associated tags.
PARAMETERS
Specifies the destination string. Specifies the string to be transformed. Specifies the maximum number of bytes to store in the trans-
formed string.
DESCRIPTION
The strxfrm() function transforms the string pointed to by the s2 parameter into an internal form suitable for collation and places the
result in the address specified by s1. This transformation is performed as appropriate to the LC_COLLATE category of the current locale.
When the strcmp() function is applied to two transformed strings, a value greater than, equal to, or less than 0 (zero) is returned. The
returned value corresponds to the same value that is returned when the strcoll() function is applied to the same two original transformed
strings. The transformed string can be longer than the original string. No more than n characters are placed in the location pointed to
by the s1 parameter, including the terminating null character. When n is 0 (zero), the s1 parameter can be a null pointer. When operating
on overlapping strings, the behavior of this function is unreliable.
NOTES
If you are doing multiple comparisons using the same set of text strings, the strxfrm() transformation function in conjunction with the
strcmp() function may be more efficient than using the strcoll() collation function because the string is transformed based on the locale
tables only once. However, the transformation function must convert all characters in the string for each level of a multi-level colla-
tion. In comparison, the collation function stops comparing characters at the first inequality. These efficiency tradeoffs make the most
efficient method for a specific application dependent on both the number of repeated comparisons for each string and the contents of each
string.
RETURN VALUES
Upon successful completion, the strxfrm() function returns the number of bytes required to store the transformed string (not including the
terminating null byte). If this is greater than or equal to the value of the n parameter, which specifies the maximum number of bytes that
can be stored in s1, the contents of s1 are indeterminate.
ERRORS
If the following condition occurs, the strxfrm() function sets errno to the corresponding value. The s2 parameter contains codes outside
the domain of the collating sequence defined by the current locale.
RELATED INFORMATION
Functions: setlocale(3), strcoll(3), string(3)/strcmp(3), wcsxfrm(3)
Standards: standards(5) delim off
strxfrm(3)