How To Empty A File In Linux
RegisterLogin
How To Empty A File In Linux
Post Description: This Command Will Show You In Linux Unix System On How You Can Reduce The Size Or Empty The File
Tags: How, To, Empty, A, File, In, Linux
This Post Was Posted On Dec 06, 2009 By Webune Tutorials #2847
Post Description: This Command Will Show You In Linux Unix System On How You Can Reduce The Size Or Empty The File
Tags: How, To, Empty, A, File, In, Linux
This Post Was Posted On Dec 06, 2009 By Webune Tutorials #2847
How To Empty A File In Linux by Webune Tutorials
Welcome to Webune.
Webune offers Linux Dedicated Servers.
today we are going to show you how you can empty a file or reduce the file size by deleting all except the last five lines
for example, i have a file called http-error.log in the /var/log/ directory
first start a root session in your shell and cd to the /var/log directory:
SHELL COMMAND:
cd /var/log/
list the files in the /var/log folder:
SHELL COMMAND:
ls -la /var/log/
OUTPUT:
78452115 httpd-error.log
as you can see from the example output, the size of the httpd-error.log is 78452115
now you can use the tail command to delete all but the last file lines
SHELL COMMAND:
tail -5 httpd-error.log > httpd-error.log
now you can ls the files and you will see that all the other lines in the files have been removed
SHELL COMMAND:
ls -la /var/log/
you will notice that the file has been reduced in size
hope that helps
Leave Your Comments
Related Pages: [Add Your Website]
Post New Topic
©2011 Webune Forums - Sun Dec 18, 2011 11:38 pm
Powered by: Webune Forums V3
Powered by: Webune Forums V3