Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting lines from a file

Status
Not open for further replies.

crasho2001

Technical User
Joined
Jun 13, 2002
Messages
51
Location
TR
Hi,

I am reading a log file regularly. I want to delete lines after reading. Size of log file will not increase any more.

How can I delete lines from a file without changing log file name?

 
Hi

Probably the tool you use rewrites the file. If the file's node number changes, it is not the same file anymore and applications which had it open and wrote into it will not be able to access it anymore until you restart them.
Code:
cat /dev/null > /log/file

Feherke.
 
Hi,

"cat /dev/null" is an option but it will delete also unread lines. While I am reading the file, a new lines can be added.

For example I need to delete lines from 1 to 99.

Not the other ones.

Thank you.
 
Hi

Then
Code:
cp /log/file /tmp/watch-me
cat /dev/null > /log/file
less /tmp/watch-me
I mean, you can not remove just a part of a file on the fly.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top