Portability fix. Use features available on standard install of OS X unix tools.