LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 09-19-2003, 10:49 AM   #1
kubicon
Member
 
Registered: Aug 2003
Location: Limbo
Posts: 54

Rep: Reputation: 15
how to find out if argument is number: bash


how can I find out if an argument to bash is a number rather that anything else?
 
Old 09-19-2003, 04:12 PM   #2
footfrisbee
Member
 
Registered: Apr 2003
Distribution: Debian Sarge
Posts: 259

Rep: Reputation: 30
Do you mean an argument to a bash script? If so this works
Code:
if `echo $1 | grep -q [^[:digit:]]`; then
   echo $1 is not a number
else
   echo $1 is a number
fi
This tests the first argument ("$1") to a bash script to so if it contains anything but numbers. If so it is not a number.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
find: missing argument to `-exec' pavodive Linux - Newbie 4 10-05-2009 02:24 PM
bash: /bin/rm: Argument list too long? FiveFlat Linux - General 5 08-11-2004 11:29 PM
-bash: /bin/mv: Argument list too long balanagireddy Linux - General 2 07-27-2004 11:19 PM
How to count number of argument received by a script? philipina Linux - General 2 07-05-2004 02:35 AM
Giving multiple words as argument for bash ivanatora Linux - General 5 01-07-2004 02:04 AM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration