On Mon, Feb 24, 2014 at 10:59 PM, Fabian Raetz <fabian.ra...@gmail.com> wrote: > while calculating my phys. memory (mb) with the > folllowing shellsript i get as a result -424. > > sysctl -n hw.physmem returns 3849830400 > > ------------ > #!/bin/sh > > phys_mem_bytes=`sysctl -n hw.physmem` > phys_mem_mb=`expr $phys_mem_bytes / 1024 / 1024` > echo $phys_mem_mb > ----------
You declared "#!/bin/sh" so you are using the broune shell, not ksh - fyi. > so i tried > expr 2147483647 / 2 which returns 1073741824 while > expr 2147483648 / 2 returns -1073741824 This looks like an integer overflow: http://en.wikipedia.org/wiki/Integer_overflow Have you tried to use bc(1)? cheers richi