Mac – How to clear a file’s contents using Terminal command

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 to “Mac – How to clear a file’s contents using Terminal command”

Leave a Reply

Your email address will not be published. Required fields are marked *