Sponsored Content
Top Forums Shell Programming and Scripting Check if argument passed is an integers Post 31123 by elchalateco on Friday 1st of November 2002 01:24:14 PM
Old 11-01-2002
Check if argument passed is an integers

How do I check if the argument passed to a script is an integer?

I am writting a script that will take to integers and want to be able to check before I go on.


I am using bourne shell.

Thanks in advance
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to print all argument passed

like i have script with which i have passed arg list :eg: i/p: scriopt1 arg1 arg2 arg3 .... argn o/p: arg1 arg2 arg3 .... argn (2 Replies)
Discussion started by: RahulJoshi
2 Replies

2. Shell Programming and Scripting

How to check that passed parameters all have the same extension?

$ ls monkey.txt banana.csv tree.txt $ myscript monkey.txt tree.txt All extensions ARE alike. $ myscript *txt All extensions ARE alike. $ myscript monkey.txt banana.csv All extensions are NOT alike. $ myscript * All extensions are NOT alike. My brain has given up; what's the simplest... (11 Replies)
Discussion started by: cs03dmj
11 Replies

3. Shell Programming and Scripting

File not recognized when passed as argument

I have the below script in file read_file.ksh if ] || ] then echo "Required one input file" echo "Enter a file to get char count:" read $FILE_NAME if ] then echo "valid file" else echo "Not a valid file." fi When run as read_file.ksh detail.csv or... (9 Replies)
Discussion started by: michaelrozar17
9 Replies

4. Shell Programming and Scripting

Check if passed arguments is users

i want to check passed arguments one by one and if it is user print home director of that user (3 Replies)
Discussion started by: testman84
3 Replies

5. Shell Programming and Scripting

shell script for ftp files passed in command line argument

i want to write a shell script function that will ftp the files passed in the command line . i have written a shell script for ftp but how will it do for all files passed in command line argument , i am passing 4 files as argument ./ftp.sh file1 file2 file3 file4 code written by me... (5 Replies)
Discussion started by: rateeshkumar
5 Replies

6. Shell Programming and Scripting

Shell script that check the argument passed to it and prints error if test condition is not met

I want to make a script that check for the argument passed to it and generates an error in case any character/string argument passed to it. I am using below code, but its not working. can anyone help. #!/bin/bash if ]; then echo 'An integer argument is passed to the script hence... (3 Replies)
Discussion started by: mukulverma2408
3 Replies

7. Shell Programming and Scripting

Variable passed as argument

I have a script. #!/bin/sh cur_$1_modify_time=Hello echo "cur_$1_modify_time" When I run like sh /root/script1 jj I expect value "Hello" being assigned to variable "cur_jj_modify_time" and output being "Hello" ie echoing $cur_jj_modify_time But the output comes as # sh... (3 Replies)
Discussion started by: anil510
3 Replies

8. Shell Programming and Scripting

Grep float/integers but skip some integers

Hi, I am working in bash in Mac OSX, I have following 'input.txt' file: <INFO> HypoTestTool: >>> Done running HypoTestInverter on the workspace combined <INFO> HypoTestTool: The computed upper limit is: 11 +/- 1.02651 <INFO> HypoTestTool: expected limit (median) 11 <INFO> HypoTestTool: ... (13 Replies)
Discussion started by: Asif Siddique
13 Replies

9. How to Post in the The UNIX and Linux Forums

Read a json file passed as cmd line argument

usage: myscript.sh config.json config.json: { "HOST":"abc", "DB_NM":"xyz", "USR_NM":"asd", "PWD":"xxx", ......... ......... ......... ........ } myscript.sh: (2 Replies)
Discussion started by: RGRT
2 Replies

10. Shell Programming and Scripting

Getting number of argument passed to a shell script

Hi Experts, I have been trying to work on a simple shell script that will just add the two argument passed to it. Here is what i tried : #!/bin/bash welcome(){ echo "Welcome to this Progg. which will accept two parameter" } main_logic(){ arg=$# echo "Number of argument passed is... (4 Replies)
Discussion started by: mukulverma2408
4 Replies
regcmp(3)						     Library Functions Manual							 regcmp(3)

NAME
regcmp, regex - Compile and execute regular expression LIBRARY
Standard C Library (libc.so, libc. a) SYNOPSIS
#include <libgen.h> char *regcmp( const char *string1, ... /*, (char *)0 */); char *regex( const char *re, const char *subject, ... ); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: regcmp(), regex(): XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Points to the string that is to be matched or converted. Points to a compiled regular expression string. Points to the string that is to be matched against re. DESCRIPTION
The regcmp() function compiles a regular expression consisting of the concatenated arguments and returns a pointer to the compiled form. The end of arguments is indicated by a null pointer. The malloc() function is used to create space for the compiled form. It is the responsibility of the process to free unneeded space so allocated. A null pointer returned from regcmp() indicates an invalid argument. The regex() function executes a compiled pattern against the subject string. Additional arguments of type char must be passed to receive matched subexpressions back. A global character pointer, __loc1, points to the first matched character in the subject string. The regcmp() and regex() functions support the simple regular expressions which are defined in the grep(1) reference page, but the syntax and semantics are slightly different. The following are the valid symbols and their associated meanings: The left and right bracket, asterisk, period, and circumflex symbols retain their meanings as defined in the grep(1) reference page. A dollar sign matches the end of the string; matches a new line. Used within brackets, the hyphen signifies an ASCII character range. For example [a-z] is equivalent to [abcd...xyz]. The - (hyphen) can represent itself only if used as the first or last character. For example, the character class expression []-] matches the characters ] (right bracket) and - (hyphen). A regular expression followed by a + (plus sign) means one or more times. For example, [0-9]+ is equivalent to [0-9][0-9]*. Integer values enclosed in {} braces indicate the number of times the pre- ceding regular expression can be applied. The value m is the minimum number and u is a number, less than 256, which is the maximum. The syntax {m} indicates the exact number of times the regular expression can be applied. The syntax {m,} is analogous to {m,infinity}. The + (plus sign) and * (asterisk) operations are equivalent to {1,} and {0,}, respectively. The value of the enclosed regular expression is returned. The value is stored in the (n+1)th argument following the subject argument. A maximum of ten enclosed regular expressions are allowed. The regex() function makes its assignments unconditionally. Parentheses are used for grouping. An operator, such as *, +, or {}, can work on a single character or a regular expression enclosed in parentheses. For example, (a*(cb+)*)$0. Since all of the symbols defined above are special characters, they must be escaped to be used as themselves. NOTES
The regcmp() and regex() interfaces are scheduled to be withdrawn from a future version of the X/Open CAE Specification. These interfaces are obsolete; they are guaranteed to function properly only in the C/POSIX locale and so should be avoided. Use the POSIX regcomp() interface instead of regcmp() and regex(). RETURN VALUES
Upon successful completion, the regcmp() function returns a pointer to the compiled regular expression. Otherwise, a null pointer is returned and errno may be set to indicate the error. Upon successful completion, the regex() function returns a pointer to the next unmatched character in the subject string. Otherwise, a null pointer is returned. RELATED INFORMATION
Commands: grep(1) Functions: malloc(3), regcomp(3) Standards: standards(5) delim off regcmp(3)
All times are GMT -4. The time now is 09:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy