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 07-19-2005, 07:52 PM   #1
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,333

Rep: Reputation: 54
clear file?


Is there a command I can use to clear the contents of a file, without having to delete it then "touch" it? I want to do this that way it will preserve the ownership and permissions. I have a script that runs and does bayeslearn on set folders so I want it to delete all the emails every time, since that makes more sense then leaving it.
 
Old 07-19-2005, 07:57 PM   #2
IamDaniel
Member
 
Registered: Mar 2003
Location: Sungai Petani
Distribution: Slackware
Posts: 143

Rep: Reputation: 15
simple:

Code:
~$ > _filename_to_clear.txt
 
Old 07-19-2005, 08:17 PM   #3
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,333

Original Poster
Rep: Reputation: 54
Oh right.. never thought of doing that. thanks.
 
Old 07-19-2005, 08:47 PM   #4
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,333

Original Poster
Rep: Reputation: 54
Hmm that does not seem to keep the attributes. It just corrupted the mbox file or something, can't access it. A blank file is suppost to work usually.
 
Old 07-19-2005, 09:00 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Not necessarily if it's being written to while you clear it ...
 
Old 07-19-2005, 09:27 PM   #6
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,333

Original Poster
Rep: Reputation: 54
ok my bad, I put echo > and not just >. I just assumed you meant echo >. it seems to work now. Got a nice rotation system going on as well with my cron email account, each week the inbox is moved to archive1, then 2, then 3 etc... using this method and cat.
 
  


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
clear or disable file cache acristescu Linux - General 3 11-04-2005 10:25 AM
SELinux: How can I clear the context when I copy a file? walkinmud Linux - Enterprise 3 08-09-2005 11:23 PM
SELinux: How can I clear the context when I copy a file? walkinmud Linux - Security 1 08-09-2005 12:37 AM
Eays way to clear a log file? extremebfn Linux - General 2 01-16-2005 04:05 AM
can not clear log file messages mitch_lin Red Hat 2 04-25-2004 08:19 PM

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

All times are GMT -5. The time now is 01:55 AM.

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