LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   checking for an integer (https://www.linuxquestions.org/questions/linux-newbie-8/checking-for-an-integer-932140/)

Micky12345 03-01-2012 08:36 AM

checking for an integer
 
i want to check whether entered argument is an integer using if

anyone can u help me??

Satyaveer Arya 03-01-2012 08:43 AM

What code you are using? what argument have you entered? what have you tried so far? Please be more specific, give more details....

Micky12345 03-01-2012 09:13 AM

i have passed a number like 340

nd my code was
Quote:

echo $1 | grep '^[0-9]$'
echo $?
but always i m getting as 1
whatevr may be the argument

catkin 03-01-2012 11:21 AM

Code:

if [[ $1 =~ ^[0-9]+$ ]; then


All times are GMT -5. The time now is 10:52 PM.