bash test check validate if variable is number

varNUM=12345; re='^[0-9]+$'; if ! [[ $varNUM =~ $re ]] ; then echo "error: Not a number"; fi
to test check if given variable is a digit / number
Sample Output
error: Not a number

0
By: aysadk
2019-07-26 09:15:37

What Others Think

Three things regarding the given solution: 1. It does not handle negative integers. 2. It does not handle the the '+' sign 3. No need to use 'if', i.e. here is shorter version of the original solution: varNUM=12A45; re='^[0-9]+$'; [[ ! $varNUM =~ $re ]] && echo "error: Not a number"
forouharid · 152 weeks and 3 days ago
really learned alot here thanks. but this one is abit outdated. are there any recent updates with breastaugmentationwichitaks.com ?
looneyhans · 83 weeks ago
really learned alot here thanks. but this one is abit outdated. are there any recent updates with breastaugmentationwichitaks.com ?
looneyhans · 83 weeks ago
really learned alot here thanks. but this one is abit outdated. are there any recent updates with breastaugmentationwichitaks.com ?
looneyhans · 83 weeks ago
Here they have shared the code for validation and hope it will be useful for those who were in search of the code that helps in validating whether the variable is a number or not so I really recommend everyone who wishes to know about the coding related doubts should definitely follow this site cbd benefits
Juvanta · 81 weeks and 1 day ago
Whoa! I just can't believe I found this site home health care fort worth
aegyjingoo · 64 weeks and 4 days ago
Important reminder cryo facial lubbock
geebranz · 58 weeks and 5 days ago
You can learn so many such commands from here and students who are really interested in learning such build your own engagement ring commands will definitely visit this website. The above command is used to bash test checks to validate if a variable is a number. I am looking here for more such commands from here.
Alyssalauren · 33 weeks and 2 days ago
where to get shrooms dried mushrooms african pyramid mushroom african transkei mushroom albino penis envy b+ mushrooms blue meanies mushroom brazilian magic mushroom burmese mushroom golden teacher mushroom ko samui super strain malabar coast martinique mexican mushroom mushroom british columbia super thai mushroom nepalese chitwan mushroom penis envy texas penis envy 6 texas yellow caps vietnamese white jedi mind fuck tri coloured ecuadorian mushroom magic mushsroom edibles mexican cubensis psychedelic chocolate bar where to get shrooms dried mushrooms african pyramid mushroom african transkei mushroom albino penis envy b+ mushrooms blue meanies mushroom brazilian magic mushroom burmese mushroom golden teacher mushroom ko samui super strain malabar coast martinique mexican mushroom mushroom british columbia super thai mushroom nepalese chitwan mushroom penis envy texas penis envy 6 texas yellow caps vietnamese white jedi mind fuck tri coloured ecuadorian mushroom magic mushsroom edibles mexican cubensis psychedelic chocolate bar midnight mint psychedelic chocolate bar origin mango psilo gummies 0.25g-1g origin strawberry psilo gummies 0.25g-1g penis envy psychedelic chocolate bar psilocybin cube gummies vegan dark chocolate psychedelic chocolate bar microdoses brain capsules 50mg-200mg chill capsules 50mg-200mg clarity capsules 50mg-200mg health capsules 50mg-200mg love capsules 50mg-200mg mood capsules 50mg-200mg pure capsules 50mg-200mg social capsules 30 pack 350mg social capsules 5 pack 350mg
johnson20007 · 21 weeks and 2 days ago
IT LABS PRO est la meilleure société de services d'ingénierie informatique au Maroc, en vous déplaçant à son siège à Marrakech - gueliz vous allez bénéficier des meilleurs services de création de sites et applications de gestion web, cette dernière privilégie ses clients et mettez à leur disposition toutes ses ressources pour l'accomplissement de leurs projets tout en offrant son expertise en conseillant ses clients et les accompagnant pour améliorer leurs images sur intérêt et mieux gérer leurs business. Creation site web maroc
itlabspro · 13 weeks and 5 days ago
If you want to buy a new premium design coat so here's we have Sienna Miller Poncho Style Coat which we made from high-quality wool fabric and the quality of this amazing Sienna Miller Poncho will never disappoint you so why are you thinking anymore buy this stunning poncho-style coat now.
emmawatson3848 · 3 weeks and 4 days ago
Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com - Commandlinefu.Com
seofox · 2 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: