Visit the LQ Articles and Editorials section
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 09-19-2003, 11:49 AM   #1
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, 05:12 PM   #2
Registered: Apr 2003
Distribution: Debian Sarge
Posts: 259

Rep: Reputation: 30
Do you mean an argument to a bash script? If so this works
if `echo $1 | grep -q [^[:digit:]]`; then
   echo $1 is not a number
   echo $1 is a number
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.


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 03:24 PM
bash: /bin/rm: Argument list too long? FiveFlat Linux - General 5 08-12-2004 12:29 AM
-bash: /bin/mv: Argument list too long balanagireddy Linux - General 2 07-28-2004 12:19 AM
How to count number of argument received by a script? philipina Linux - General 2 07-05-2004 03:35 AM
Giving multiple words as argument for bash ivanatora Linux - General 5 01-07-2004 03:04 AM

All times are GMT -5. The time now is 04:04 AM.

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