#!/usr/bin/sed -f # commify numbers /[0-9]\{4,\}/ { s/$/ / : SUB s/\([0-9]\)\([0-9]\{3\}[^0-9]\)/\1,\2/g t SUB s/ $// }