I don't know how to use awk, but I have a problem which I know it suits for.
I want to sum up memory usage data that come out from executing the command ps aux. I learned 2 usages of awk from this lesson.
Print value of a column with:
awk '{ print $COLUMN_NUMBER }'
Sum value of a column with:
awk '{ temp = temp + $COLUMN_NUMBER }END{ print temp }'
So I can get sum of memory usage of processes with certain name pattern like this:
$ ps aux | grep NAME_PATTERN | awk '{temp = temp + $6}END{ print temp }'
I still don't know awk, but at least I'm incrementally learning it.
Credits:
simple awk tutorial
Add up a column of numbers at the Unix shell
Subscribe to:
Post Comments (Atom)
Collectd PostgreSQL Plugin
I couldn't find this link when searching with google https://www.collectd.org/documentation/manpages/collectd.conf.html#plugin-postgresq...
-
sudo su postgres supply your Mac password modify /Library/PostgreSQL/9.x/data/pg_hba.conf from local all all md5 to local all all ...
-
Put your cursor on the text box of the post/comment you want to indent Go to the menubar at the top of the screen Edit > Emoji & ...
-
I ran to this error the other day when I tried to export a dump file from a slave Postgres database. cpg_dump: Dumping the contents of ta...
No comments:
Post a Comment