Install Ubuntu truncate command to Mac OS X 10.7
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
.
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:
http://mxcl.github.com/homebrew/
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
When truncate
is not available you can often use dd
instead. Eg.
Make a file full of zeros:
dd if=/dev/zero of=/tmp/youroutputfile bs=1m count=50
Truncate an existing file:
dd if=yourinputfile of=/tmp/youroutputfile bs=1k count=1
Note: the OS X dd
uses lower case unit letters where GNU dd
uses upper case.