LinuxQuestions.org
Help answer threads with 0 replies.
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
 
LinkBack Search this Thread
Old 06-03-2006, 07:57 PM   #1
judgex
LQ Newbie
 
Registered: Jan 2006
Location: Australia
Distribution: Fedora Core 4 and Cygwin
Posts: 14

Rep: Reputation: 0
Test variable is an integer in shell


How do I test a variable is an integer in shell?
 
Old 06-03-2006, 10:12 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,116
Blog Entries: 9

Rep: Reputation: 627Reputation: 627Reputation: 627Reputation: 627Reputation: 627Reputation: 627
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
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Test for integer in BASH minil Programming 18 02-01-2012 01:45 AM
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 04:23 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
Open Source Consulting | Domain Registration