Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete content of a log file from linux terminal?

Tags:

linux

terminal

I have a log file on server called writelog which is about 2GB.

I want to delete first 100,000 lines from the file. I could open the file and delete those lines but because of the file size it takes me forever to download it.

So, is it possible to do this from Linux terminal? If yes how?

like image 520
Sushan Ghimire Avatar asked Sep 06 '12 14:09

Sushan Ghimire


1 Answers

If you want to clear out the whole file a quick way is

cat /dev/null > writelog

See also this thread on unix.com.

like image 189
roblogic Avatar answered Nov 15 '22 06:11

roblogic