Hi all,
Does anyone know how to simulate a ceiling or floor function in UNIX? OS is Solaris. I tried the suggestion from an old forum but it is giving me error as below:
server01[]/tmp$: echo "7.2" | awk '{printf("%d\n",$0+=$0<0?0:0.999)}'
awk: syntax error near line 1
awk: illegal statement near line 1
Am looking for something "simple", echo "7.123" | ceiling or echo "7.123" | floor that should return 8 or 7 respectively or something like that. Won't mind having to use awk i fneed be, but not sure how to call the function. I've also tried the one below but same error:
server01[]/tmp$: echo "7.2" | awk 'function ceil(valor) { return (valor == int(valor)) ? valor : int(valor)+1 } { printf "%d", ceil($1) }'
awk: syntax error near line 1
awk: bailing out near line 1
Any suggestion will be much appreciated. Thanks in advance.