• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Empty A File

December 21, 2017

If you work with vi, nano or any other command line editor, deleting a line is a fairly easy thing to do. If the file is too large, deleting the content line by line is not fun. There’s a better way to empty a file without deleting it. Here are several ways.

$ > filename
$ truncate -s 0 filename
$ echo "" > filename

$ > filename $ truncate -s 0 filename $ echo "" > filename

Filed Under: Linux

Search This Website

Subscribe Via Email

  • Home
  • About
  • Archives

Copyright © 2023