0

who is using the most memory

simple sort to show which application is using the most memory. ps -elf | awk ‘{print $10, $3, $4, $15, $16}’| sort -nr | head 572923 mysql 1246 /usr/libexec/mysqld –basedir=/usr 257775 root 6260 /usr/bin/python /usr/bin/fail2ban-server 176636 clamav 1086 clamd 146010 2001 27443 /usr/sbin/httpd 122691 apache 30546 /usr/sbin/httpd 121580 apache 27444 /usr/sbin/httpd 121410 apache 6437 /usr/sbin/httpd 121362 apache 6438 /usr/sbin/httpd 121223 apache 6439 /usr/sbin/httpd 121222 apache 6428 /usr/sbin/httpd in my case its mysqld.

0

Cool AWK trick – remove duplicate lines without sort

I always do something like cat file | sort -n | uniq to get a unique listing of a file to remove duplicates. the only problem with this is that it sorts the list so the ordering of the file is lost.. found a cool trick with AWK today of removing duplicate lines without destroying the order and yet its just a one liner! awk ‘!a[$0]++’ file lets take an example $ cat abc ddd bbb eee fff aaa ccc bbb kkk aaa zzz xxx yyy now : $ awk ‘!a[$0]++’ abc ddd bbb eee fff aaa ccc kkk zzz… Continue Reading

0

awk stuff

print all lines in a file that match some pattern awk ‘$0 ~ /pattern/ {print $0}’ awk ‘NR % 6’ # prints all lines except those divisible by 6 awk ‘NR > 5’ # prints from line 6 onwards (like tail -n +6, or sed ‘1,5d’) awk ‘$2 == “foo”‘ # prints lines where the second field is “foo” awk ‘NF >= 6’ # prints lines with 6 or more fields awk ‘/foo/ && /bar/’ # prints lines that match /foo/ and /bar/, in any order awk ‘/foo/ && !/bar/’ # prints lines that match /foo/ but not /bar/ awk… Continue Reading