LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 10-03-2002, 05:27 PM   #1
Road
Member
 
Registered: Jan 2002
Distribution: Debian Based only but have tried most others.
Posts: 82

Rep: Reputation: 15
Deleting contents of files.


I am trying to script a process and I am trying to figure out how to delete the contents of a file without deleting the entire file and then recreating it.

This would also be useful to delete the information contained inside a log but not actally delete the entire log itself.

I have explored cat, touch, and vi and I have not found what I am looking for. Did I miss something or is there another command?

Thanks,

Road
 
Old 10-03-2002, 05:40 PM   #2
markus1982
Senior Member
 
Registered: Aug 2002
Location: Stuttgart (Germany)
Distribution: Debian/GNU Linux
Posts: 1,467

Rep: Reputation: 45
Well, the solution is simple:
Code:
cat /dev/null > filename
 
Old 10-03-2002, 06:02 PM   #3
leed_25
Member
 
Registered: Jul 2002
Location: san francisco
Distribution: freebsd
Posts: 102

Rep: Reputation: 16
discard file contents

in the (bash) shell I'm using --and in the korn and bourne shells-- this is sufficient:

$ >file

note: dollar sign ($) is the shell prompt
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to search files with specific contents ? sachinh Linux - Security 4 07-22-2004 08:00 AM
Comparing files contents? hhegab Linux - Newbie 3 07-01-2004 12:45 AM
to compare the contents of 2 files MaleWithBrains Linux - Newbie 3 01-27-2004 06:39 PM
Contents of Binutils, Book 4.1, Ch 5.8, missing .so files itsjustme Linux From Scratch 1 07-22-2003 07:42 PM
Deleting files Tingle Linux - Newbie 4 01-16-2003 04:19 PM


All times are GMT -5. The time now is 09:58 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration