Ash Adams
Ash Adams

Reputation: 15

kB to MB using awk

I have a script:

bash -c "echo \$[\$(egrep '^Commit(Limit|ted_AS): ' /proc/meminfo | awk '{ print \$2 }' | tr '\n' '-')0]"

which returns result in Kb and I need to convert it to Mb by dividing it to 1024.

Upvotes: 1

Views: 432

Answers (1)

Cyrus
Cyrus

Reputation: 88654

With awk:

awk '/^Commit/{print $1,$2/1024,"Mb"}' /proc/meminfo

Output:

CommitLimit: 5536.77 Mb
Committed_AS: 13280.3 Mb

Upvotes: 1

Related Questions