Sponsored Content
Top Forums Shell Programming and Scripting How to check whether a string is number or not Post 83979 by shihabvk on Wednesday 21st of September 2005 06:25:57 AM
Old 09-21-2005
Hi rishi ,
It won't work if the number is like +567
example expr +567 + 1 .. will fail


Regards
Shihab
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

check whether variable number or string

I am passing an argument to a file and i wanna check whether the argument is a number or string ? how can i do this? (4 Replies)
Discussion started by: rolex.mp
4 Replies

2. Shell Programming and Scripting

read string, check string length and cut

Hello All, Plz help me with: I have a csv file with data separated by ',' and optionally enclosed by "". I want to check each of these values to see if they exceed the specified string length, and if they do I want to cut just that value to the max length allowed and keep the csv format as it... (9 Replies)
Discussion started by: ozzy80
9 Replies

3. Shell Programming and Scripting

how to search string and number in one file and check in the other file

Hi, Can anyone help in the below problem. file1 has the below contents fileset 999 primary-ilist inode 37020 has invalid dotdot (426094) -> Not exist fileset 999 primary-ilist inode 115016 dup block ->... (9 Replies)
Discussion started by: knshree
9 Replies

4. Shell Programming and Scripting

How to Check given string is number in shell script?

Hi, Can anyone help me out to check whether the input argument is number? Example: REQUEST_ID="123456" I need to check the REQUEST_ID value is number or string. Thanks in Advance Regards BS (6 Replies)
Discussion started by: balajiora
6 Replies

5. Shell Programming and Scripting

Check if the value is Number

Hi, I have a file with data as given $cat file1.txt 123 234 23e 234.456 234.876e 345.00 I am checking if the values are proper integers using the command. nawk -F'|' 'int($1)!=$1 {printf "Error in field 1|"$0"\n"}' file1.txt This is checking for only integers ( without... (10 Replies)
Discussion started by: ashwin3086
10 Replies

6. Shell Programming and Scripting

changing number in bash (number is in form of string)

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)
Discussion started by: Learnerabc
3 Replies

7. Shell Programming and Scripting

Check parameter is number or string

Hey I'm new in linux, I'm looking for a code to check whether the parameter is a number or a string. I have already tried this code: eerste=$(echo $1 | grep "^*$">aux) if But it doesn't work.:confused: Thanks (2 Replies)
Discussion started by: Eclecticaa
2 Replies

8. Shell Programming and Scripting

Check file for string existence before appending it with string

I want to append file with a string but before doing that i want to check if this string already exist in that file.I tried with grep on Solaris 10 but unsuccessful.Man pages from grep seems to suggest if the string is found command status will be 0 and if not 1.But i am not finding it.May be i... (2 Replies)
Discussion started by: sahil_shine
2 Replies

9. UNIX for Beginners Questions & Answers

Concatenate a string and number and compare that with another string in awk script

I have below code inside my awk script if ( $0 ~ /SVC IN:/ ) { svc_in=substr( $0,23 , 3); if (msg_start == 1 && msg_end == 0) { msg_arr=$0; } } else if ( $0 ~ /^SVC OUT:/ ) { svc_out=substr( $0, 9, 3); if (msg_start == 1 && msg_end == 0) ... (6 Replies)
Discussion started by: bhagya123
6 Replies
STRFMON(3)						     Linux Programmer's Manual							STRFMON(3)

NAME
strfmon - convert monetary value to a string SYNOPSIS
#include <monetary.h> ssize_t strfmon(char *s, size_t max, const char *format, ...); DESCRIPTION
The strfmon() function formats the specified amounts according to the format specification format and places the result in the character array s of size max. Ordinary characters in format are copied to s without conversion. Conversion specifiers are introduced by a `%' character. Immediately following it there can be zero or more of the following flags: =f The single-byte character f is used as the numeric fill character (to be used with a left precision, see below). When not speci- fied, the space character is used. ^ Do not use any grouping characters that might be defined for the current locale. By default, grouping is enabled. ( or + The ( flag indicates that negative amounts should be enclosed between parentheses. The + flag indicates that signs should be handled in the default way, that is, amounts are preceded by the locale's sign indication, e.g., nothing for positive, "-" for negative. ! Omit the currency symbol. - Left justify all fields. The default is right justification. Next, there may be a field width: a decimal digit string specifying a minimum field width in bytes. The default is 0. A result smaller than this width is padded with spaces (on the left, unless the left-justify flag was given). Next, there may be a left precision of the form "#" followed by a decimal digit string. If the number of digits left of the radix character is smaller than this, the representation is padded on the left with the numeric fill character. Grouping characters are not counted in this field width. Next, there may be a right precision of the form "." followed by a decimal digit string. The amount being formatted is rounded to the spec- ified number of digits prior to formatting. The default is specified in the frac_digits and int_frac_digits items of the current locale. If the right precision is 0, no radix character is printed. (The radix character here is determined by LC_MONETARY, and may differ from that specified by LC_NUMERIC.) Finally, the conversion specification must be ended with a conversion character. The three conversion characters are % (In this case the entire specification must be exactly "%%".) Put a `%' character in the result string. i One argument of type double is converted using the locale's international currency format. n One argument of type double is converted using the locale's national currency format. RETURN VALUE
The strfmon() function returns the number of characters placed in the array s, not including the terminating NUL character, provided the string, including the terminating NUL, fits. Otherwise, it sets errno to E2BIG, returns -1, and the contents of the array is undefined. EXAMPLE
The call strfmon(buf, sizeof(buf), "[%^=*#6n] [%=*#6i]", 1234.567, 1234.567); outputs [ fl **1234,57] [ NLG **1 234,57] in the Dutch locale (with fl for "florijnen" and NLG for Netherlands Guilders). The grouping character is very ugly because it takes as much space as a digit, while it should not take more than half that, and will no doubt cause confusion. Surprisingly, the "fl" is preceded and followed by a space, and "NLG" is preceded by one and followed by two spaces. This may be a bug in the locale files. The Italian, Aus- tralian, Swiss and Portuguese locales yield [ L. **1235] [ ITL **1.235] [ $**1234.57] [ AUD **1,234.57] [Fr. **1234,57] [CHF **1.234,57] [ **1234$57Esc] [ **1.234$57PTE ] SEE ALSO
setlocale(3), sprintf(3), locale(7) Linux 2000-12-05 STRFMON(3)
All times are GMT -4. The time now is 06:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy