Tag Archive ‘awk’

 

CharlyBr on Apr 17th, 2009Finding the total size of a set of files with awk

If you need to sum the total size of files in a directory or matching a pattern, an easy solution is to use awk.
I needed to calculate this total for a set of javascript files, I used this command line:
$ find App/ -name ‘*.js’ -exec ls -l \{\} \; | awk ‘{sum+=$5} END {print sum}’
1929403
For [...]

CharlyBr on Mar 13th, 2009Memory usage by group of processes

While monitoring a http/php server, I needed to do some statistics about php-cgi memory usage.
Playing with memory_limit in PHP, we wanted to know the average memory usage per php-cgi process. This is easily calculated with our best friend awk.
First, get the number of php running processes:
# ps aux | grep php-cgi | grep -v grep [...]

CharlyBr on Sep 22nd, 2008About user agent strings

I was surprised when I saw the length of the Chrome user agent string last week:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.X.Y.Z Safari/525.13
And in our logs:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.29 Safari/525.13
a user agent string of 119 characters. It looks quite a waste of [...]