Sponsored Content
Top Forums Shell Programming and Scripting Find first digit in string using expr index Post 302233076 by ghostdog74 on Friday 5th of September 2008 10:26:48 PM
Old 09-05-2008
you can use expr match. Check the Manipulating Strings document again. read carefully
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

why "expr "${REPLY}" : '\([1-9][[:digit:]]*\)" can figure out whether it is a digit?

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

Find index of last occurence of a character within a string

I need to find the index of last '|' (highlighted in bold) in awk : |ifOraDatabase.Lastservererr<>0then|iferr_flag<>0then|end if Please suggest a way... Thanks (5 Replies)
Discussion started by: joyan321
5 Replies

3. UNIX for Dummies Questions & Answers

string index

I have a line "My name is Deepak" How can i search a string Deepak in the line and find out its index position. Here in this case the result should be 12. (3 Replies)
Discussion started by: dr46014
3 Replies

4. Programming

Find out 2^n+1 , where n is a 3 digit number

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

5. Shell Programming and Scripting

Creating 12 digit string value

Hi Masters, here is my req I have to create a 12 digit string which includes the user i/p Like if user input 2334 then the string will be 233411111111 ,if the user inputs 23345 then the string will be 233451111111 , So we dont know how many digits will the user inputs output will be 12... (16 Replies)
Discussion started by: Pratik4891
16 Replies

6. UNIX for Dummies Questions & Answers

how to get index/postion of a string?

Hi, I have a string like the following: /db1/data/GLIDER/SYSTEM.dbf need to find the postion where "SYSTEM.dbf" starts, so I tried: LOCATION=/db1/data/GLIDER/SYSTEM.dbf $ expr index $LOCATION SYSTEM expr: syntax error $ expr index "$LOCATION" SYSTEM expr: syntax error ... (5 Replies)
Discussion started by: seafan
5 Replies

7. 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

8. 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

9. Shell Programming and Scripting

How to use expr INDEX with pipe?

Hi, I need to use the output of previous command in the next command while using pipe. Like I am reading a file then I am fetching first line from a file and then I want to know the location of character 'e' in that line. cat filename|sed -n 1p|expr index ------ e In above example I... (5 Replies)
Discussion started by: Peeyush Sehgal
5 Replies

10. 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
ecvt(3C)																  ecvt(3C)

NAME
ecvt(), fcvt(), gcvt() - convert floating-point number to string SYNOPSIS
Obsolescent Interfaces DESCRIPTION
Converts value to a null-terminated string of ndigit digits and returns a pointer to the string. The high-order digit is non-zero, unless the value is zero. The low-order digit is rounded. The position of the radix character relative to the beginning of the string is stored indirectly through decpt (negative means to the left of the returned digits). The radix character is not included in the returned string. If the sign of the result is negative, the word pointed to by sign is non-zero, otherwise it is zero. One of three non-digit characters strings could be returned if the converted value is out of range. A or is returned if the value is larger than the exponent can contain, and is negative, or positive, respectively. The third string is returned if the number is illegal, a zero divide for example. The result value is Not A Number (NAN) and would return a character. Identical to except that the correct digit has been rounded for printf (FORTRAN F-format) output of the number of digits specified by ndigit. Converts the value to a null-terminated string in the array pointed to by buf and returns buf. It produces ndigit significant digits in FORTRAN F-format if possible, or E-format otherwise. A minus sign, if required, and a radix character is included in the returned string. Trailing zeros are suppressed. The radix character is determined by the currently loaded NLS environment (see setlocale(3C)). If has not been called successfully, the default NLS environment, "C", is used (see lang(5)). The default environment specifies a period as the radix character. Obsolescent Interfaces and convert floating-point number to string. EXTERNAL INFLUENCES
Locale The category determines the value of the radix character within the current NLS environment. WARNINGS
The values returned by and point to an array whose content is overwritten by subsequent calls to these interfaces by the same thread. and are obsolescent interfaces supported only for compatibility with existing DCE applications. New multi-threaded applications should use and AUTHOR
and were developed by AT&T. was developed by AT&T and HP. SEE ALSO
setlocale(3C), printf(3S), lang(5), thread_safety(5), glossary(9). STANDARDS CONFORMANCE
ecvt(3C)
All times are GMT -4. The time now is 12:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy