18.207.255.49 |    

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.003 seconds at 138.09 KB/s

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

User online
There are 3 users online.

Tags Cloud

Latest snippets
last day of last month
(Bash::Snippets)
crypt_apr1_md5
(PHP::Function)
crypt_apr1_md5
(Perl::Function)
transparent
(CSS)
rfc2822Toiso8601
(PHP::Function)
STDERR
(Bash::Function)
radius
(CSS)
shadow
(CSS)
rotate
(CSS)
create_function
(JavaScript::Snippets)