

You need -b, as sort counts columns from the end of the previous field Sort: key 1 is numeric and spans multiple fields Sort: leading blanks are significant in key 1 consider also specifying 'b' If you don't know which format (f) to use, show us what the values to be sorted look like. Use the sort -debug option to get some clues: $ echo '. For the field you want to sort on (key), p is the starting position, m is the length, f is the format and a is A for ascending sequence or D for descending sequence. Empirically I find I need to start at field position 15 to sort this data in ascending numeric order as expected: sort -k5.15n /tmp/axfr.10.1.1 However, this does not sort my data at all.

The last octet conveniently starts at character offset eight within the fifth field, so my understanding is that this command should suffice: sort -k5.8n /tmp/axfr.10.1.1 OPTS is one or more single-letter ordering options, which override global ordering options for that key. If neither -t nor -b is in effect, characters in a field are counted from the beginning of the preceding whitespace. KEYDEF is F] for start and stop position, where F is a field number and C a character position in the field both are origin 1, and the stop position defaults to the line's end. is live My academic website (/afrazee) and this blog have been merged into one fantastic nerd site,, as of today If you subscribe to this blog with RSS, you can just delete that feed and add to your reader instead (it has RSS enabled, and all the wordpress posts were ported. The man page confirms that I can use -k with not only a field but also an offset within that field, and with an n numeric modifier When using SORT on a Date/Time field, the numbers in Post Meta are stored as LONGTEXT so you need to cast them as Date & Time Fields first. In this specific case I know I can sort by just the last octet, so this should be a straightforward application of sort. Before you mark this as a duplicate, please read on a short while, because this isn't about sorting IP addresses as such ( sort -k5V would address that). I have an extract from a forward DNS zone file, which I want to sort by ascending IP address.
