LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-04-2005, 05:44 AM   #1
abdul_zu
Member
 
Registered: Feb 2005
Posts: 71

Rep: Reputation: 15
Deleting Contents of File


Hi friends,

How i can delete the whole contents of file using Perl script. I don't want to delete the file itself becuase the file is already used with some application. So i need to delete the whole contents of file.


Thank you for your time
Abdul Lateef
 
Old 12-04-2005, 07:51 AM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Here's how I do it from the command line. You could put that in the script somewhere...
Code:
>file.txt
or
echo >file.txt
 
Old 12-04-2005, 08:58 AM   #3
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,272

Rep: Reputation: 154Reputation: 154
You can do it like this I think
Code:
open(FD, ">path/to/file") || die("Can't open file");
close(FD);

Last edited by phil.d.g; 12-04-2005 at 09:00 AM.
 
Old 12-04-2005, 02:12 PM   #4
abdul_zu
Member
 
Registered: Feb 2005
Posts: 71

Original Poster
Rep: Reputation: 15
Hi,

Both are working well. and i used the last option becuase this is more close to my application.

Thank you very much for your times.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
filtering a file then deleting it. road69runners Programming 6 12-02-2004 01:54 PM
Deleting a file starting with a ? bitpicker Linux - General 6 11-24-2004 01:20 PM
deleting a file intellscreen Linux - Newbie 3 11-02-2003 12:39 PM
deleting kcore file? megaspaz Linux - General 1 11-07-2002 04:33 AM
Deleting a file...... lucifer Linux - Software 0 09-03-2002 03:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration