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 :: config git ftp 
Shell :: use odbc from powershell 
Shell :: ubuntu 20.04 uninstall all games 
Shell :: How to export a GPG private key to a file 
Shell :: git clean branches 
Shell :: packet tracer linux mint 
Shell :: bash write 
Shell :: zsh: command not found: n 
Shell :: Error: .ini file does not include supervisorctl section 
Shell :: installing rspec gemfile 
Shell :: git remove origin 
Shell :: yarn 2 outdated packages 
Shell :: install heroku 
Shell :: How can i rename my local master branch to main ? 
Shell :: how to remove installation from cent os 
Shell :: installing pipewire 
Shell :: the remote end hung up unexpectedly 
Shell :: git pull upstream 
Shell :: how to install ddos on ubuntu 
Shell :: after checkout fatal: You are not currently on a branch. 
Shell :: linux print screen 
Shell :: revert last push to server 
Shell :: how to debug wirless android 
Shell :: replace substring in shell 
Shell :: intall mondg brew 
Shell :: ubuntu install java 16 
Shell :: change commit author after push 
Shell :: how to install crome linux 
Shell :: alpine linux install redis-cli 
Shell :: how to determine the file type in ubuntu 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =