3.17.154.171 |    

Navigation

Google Advertisement

Die Function is_int() prüft ob es sich um eine integer Nummer handelt und gibt im Erfolgsfall True, im Fehlerfall False zurück.

is_int
  1. # ************************************************************
  2. # This function check, if [$number] is an integer number.
  3. # This function return 'true' if [$number] is integer otherwise
  4. # return 'false'.
  5.  
  6. function is_int () {
  7.  
  8. local number=$1
  9. [ -z "$number" ] && number="x"
  10. number=$( echo "$number" | sed 's/^[-+]*[0-9]*//g' )
  11. if [ -z "$number" ]; then true; else false; fi
  12.  
  13. }
  14.  
  15. # sample function call
  16. if ! is_int "$1" ; then
  17. 	echo "\$1 is no integer number!"; exit 1
  18. fi
Parsed in 0.002 seconds at 196.13 KB/s

Search
 
Full text search by name and content of a snippet.

User online
There are 3 users online.

Tags Cloud

Latest snippets
str2seconds
(Bash::Function)
is_integer
(Bash::Function)
file_rotate
(Bash::Function)
confirm
(Bash::Function)
is_workingtime
(Bash::Function)
last day of last month
(Bash::Snippets)
crypt_apr1_md5
(PHP::Function)
crypt_apr1_md5
(Perl::Function)
transparent
(CSS)
rfc2822Toiso8601
(PHP::Function)