Categories
mac Terminal Tutorials

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'

By Jonathan Whiting

I enjoy sharing what I am learning and hopefully it's of interest and help to you. I live in Canada with my wife. Follow me on Twitter.

2 replies on “Mac – How to clear a file’s contents using Terminal command”

Leave a Reply

Your email address will not be published.