sort (3)

Sort on nth field

To sort a text file on a particular field: [code] Sort -t: -k 4n thefile [/code] So thefile will be output, sorted by the 4th field.

count a unique field in text file

i was just perusing my access_log, and fancied counting the number of times unique ip addresses had access my site. just because. i started by using cat to see the access_log cut the first field using cut -f1 -d’ ‘ sorted that list of ip’s uniq’d it and used -c to add a count then […]

sorting on two price fields in MySQL

Sorting on two price fields in MySQL was a confusing thought at first, and was tempted to query then use php to do it. No! I needed a way to select my products and order them by price. But we have two prices, a “price” and “price_offer”, so we need to compare these values so […]