Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash if is number

re='^[0-9]+$'
if ! [[ $yournumber =~ $re ]] ; then
   echo "error: Not a number" >&2; exit 1
fi
Comment

check if variable is a number in bash

re='^[0-9]+$'
if ! [[ $yournumber =~ $re ]] ; then
   echo "error: Not a number" >&2; exit 1
fi
Comment

Bash test if variable is a number

[[ $1 == ?(-)+([0-9]) ]] && echo "$1 is an integer"
Comment

PREVIOUS NEXT
Code Example
Shell :: install zoom ubuntu 
Shell :: bash counter 
Shell :: docker output ps format 
Shell :: install nginx amazon linux 2 
Shell :: powershell print env all 
Shell :: linux give permission to folder 
Shell :: ubuntu install ssh server 
Shell :: purge apache 2 
Shell :: find depth 1 
Shell :: install dependencies @material-ui/lab/Rating 
Shell :: how to logout of git in terminal 
Shell :: macos install airport 
Shell :: install deb package 
Shell :: clean go cache 
Shell :: Failed to start Redis In-Memory Data Store. 
Shell :: how to install specific version of bootstrap using npm 
Shell :: linux install vi 
Shell :: vlc download for linux 
Shell :: ghostscript on ubuntu 
Shell :: linux compress folder 
Shell :: how to remove all commit in git 
Shell :: django knox install 
Shell :: black webbrowser 
Shell :: ionic capacitor build livereload 
Shell :: display id all image docker 
Shell :: github ssh key ubuntu 
Shell :: install jupyterlab on ubuntu 
Shell :: current year bash 
Shell :: install git ubuntu 
Shell :: close port ubuntu 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =