sg

Çarşamba, Ocak 18, 2006

[lug] Re: Linux command to over write a file with an empty file.

jdhog wrote:
> Is there a linux command which will allow me to truncate or over write
> a file to get rid of the original files contents and make it an empty
> file? My situation is that I have a log file that is growing extremely
> fast. When it gets to large, the file script that is writing to the
> file crashes. I tried copying the file to a sub directory and then
> deleting the original file. The script will create a new file if it
> doesn't exists. The problem is that cp and mv commands both seem to
> carry the symbolic link with the copied or moved file and thus the
> script keeps writing to the moved or copied file. Any help would be
> greatly appreciated.

Generally , just to be on the safe side I do this

cat /dev/null > file

This ensures the file is zero length without a \0 appended on the first
line.

On some systems cat > file appends a \0 (\n) depending on the flavor.

If all you want to do is blank a file either would work.

HTH

timtim

0 Comments:

Yorum Gönder

<< Home


Komik Videolar   islam  şarkı sözleri  yemek tarifleri  gelibolu  huzur   sağlık