LinuxQuestions.org
Have you heard the LinuxQuestions.org Podcast?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Thread Tools
Old 06-03-2006, 07:57 PM   #1
judgex
LQ Newbie
 
Registered: Jan 2006
Location: Australia
Distribution: Fedora Core 4 and Cygwin
Posts: 14
Thanked: 0
Test variable is an integer in shell


[Log in to get rid of this advertisement]
How do I test a variable is an integer in shell?
judgex is offline     Reply With Quote
Old 06-03-2006, 10:12 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :}
Posts: 18,848
Blog Entries: 1
Thanked: 160
Hi, and welcome to LQ!

Something like:
Code:
if echo $* | egrep -v "[a-zA-Z,./:]+" ; then
        echo "Is integer"
fi
You get the idea :)


Cheers,
Tink
Tinkster is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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
Test for integer in BASH minil Programming 15 06-04-2009 06:05 PM
test a variable to see if it contains information farmerjoe Programming 4 04-25-2005 03:34 PM
write() a variable(integer) to socket? koyi Programming 6 07-08-2004 10:42 AM
Test uninitialized variable AMMullan Programming 6 02-12-2004 11:29 AM
Shell-Script check if $xx is of type integer d-fens Programming 5 07-11-2003 09:38 AM


All times are GMT -5. The time now is 06:51 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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration