I'm writing a series of scripts for deploying in our support center. One that I'm working on involves /proc/kcore, the physical RAM of a linux system. I'm trying to display the amount of physical RAM in a system by returning the size of this file divided by 1024.
I'd like it to eventually say: PHYSICAL RAM: 512MB.
Here's what I've tried, and the results:
Code:
$ echo "System RAM";ls -l /proc/kcore System RAM -r-------- 1 root root 958595072 Feb 14 13:13 /proc/kcore $ $ ls -l /proc/kcore | 'expr $5/1024' /bin/ksh: expr $5/1024: not found $ ls -l /proc/kcore | echo $5 $ ls -l /proc/kcore | echo $1 $ ls -l /proc/kcore > echo $5 /bin/ksh: cannot create echo: No such file or directory $ ls -l /proc/kcore | awk "print int($5/1024)" awk: cmd. line:1: print int(/1024) awk: cmd. line:1: ^ parse error awk: cmd. line:1: print int(/1024) awk: cmd. line:1: ^ unterminated regexp awk: cmd. line:2: print int(/1024) awk: cmd. line:2: ^ unexpected newline $ ls -l /proc/kcore | awk {print int($5/1024)} /bin/ksh: syntax error: `(' unexpected $ ls -l /proc/kcore | awk `BEGIN {print int($5/1024)}' > > ^C $ $ ls -l /proc/kcore | awk `{print int($5/1024)}` /bin/ksh: syntax error: `(' unexpected $ ls -l /proc/kcore | awk -F `{print int($5/1024)}' > > ^C $ ls -l /proc/kcore | awk -F `{print int($5/1024)}' > ^C $ awk '{ print int($5/1024) }` < ls -l /proc/kcore > ^C $ ls -l /proc/kcore > temp; awk '{ print int($5/1024) }` temp > ^C
As you can see, I'm stuck on awk. Can anyone shed some light on this?
I basically want to take the 5th field of an ls and display the result of that field divided by 1024.
Anyone?
TIA!
chewy

Help










