Install Ubuntu truncate command to Mac OS X 10.7

Solution 1:

This shouldn't really be in Server Fault, probably Super User or Ask Different, but you can install a lot of binaries by using homebrew, found here:

Link

Firstly you'll need to install command line tools for Xcode, which will probably require you to purchase it if you havn't already.

Once you've done this, run:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

To install homebrew, then when it's installed, run:

brew install truncate

Solution 2:

Update:

As of March 2015 truncate is no longer available in Homebrew as a standalone formula.

As truncate is part of GNU Coreutils you should install it on OS X with the following command:

> brew install coreutils

After installation truncate will be available under the name gtruncate. Note that all programs from Coreutils will be available with the prefix g.