A quick trick to empty a file using Terminal on Mac.
1. Open Terminal
2. enter the following command in Terminal
cat /dev/null > fileName
If you get a warning Permission Denied you can do the following trick.
sudo sh -c 'cat /dev/null > fileName'
2 replies on “Mac – How to clear a file’s contents using Terminal command”
`echo “” > fileName`
Also does the trick.
Hi Gijs,
Great tip, thanks for posting