LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-16-2009, 09:49 AM   #1
chetanpatel
LQ Newbie
 
Registered: Aug 2008
Posts: 1
Blog Entries: 1

Rep: Reputation: 0
making the file containing large data empty


Hi all
I want to make a file empty which contain some data.
I am trying as follows
echo "" > filename.
but it is not working.
Please help
 
Old 03-16-2009, 10:12 AM   #2
JaksoDebr
Member
 
Registered: Mar 2009
Distribution: Fedora, Slackware
Posts: 104

Rep: Reputation: 21
This depends on what you mean by empty. An empty file is usually a file with zero-byte length. Sometimes a file containing any number of zero-bytes is also called empty. A file with some specific file file type, like a TIFF image, that contains the file structure, but no image at all, can also be called empty.

Your attempt with 'echo "" > filename' only gives a zero-length file - obviously not what you want.

To create a file containing NULL bytes you can use the 'dd' command by using /dev/null as the input (something like 'dd if=/dev/null of=your.file', but read the man page first).

To keep a specific file format, but removing custom content data, you still have to keep the file format intact. An empty OpenOffice document, for example, is one that doesn't contain custom text - the same as a newly created document.

JD

Linux Archive

Last edited by JaksoDebr; 04-02-2009 at 06:11 AM.
 
Old 03-16-2009, 12:27 PM   #3
malekmustaq
Senior Member
 
Registered: Dec 2008
Location: root
Distribution: Slackware & BSD
Posts: 1,615

Rep: Reputation: 441Reputation: 441Reputation: 441Reputation: 441Reputation: 441
Quote:
Originally Posted by chetanpatel View Post
Hi all
I want to make a file empty which contain some data.
I am trying as follows
echo "" > filename.
but it is not working.
Please help
==========================

chetanpatel:

You said: "I want to make a file empty which contain some data."

Answer 1: If you truly mean CREATING (make) "file" that contains nothing do this:

$ touch <filename>

this creates an empty file. Check if it is there: ls -l <filename>

Answer 2: But if you mean a "folder" (since folder is considered file) do this:

$ cd <folder> (that's to get inside the folder)
$ rm -rf * (that deletes all files inside it and subfolders as well)

==>Notabene: This rm -fr is dangerous, be certain what you are doing. Also it cannot delete files/folders that you did not create: to overcome this you must login as root first then cd to the directory folder the contents of which you wanted to delete. Sometimes you need to own them first by chown if the UID that created it belonged somewhere from other galaxy; do this:

# chown root:root *

then you can execute the verdict above.

[The multitude of my answers sprang out not from my loquacity but from my sincere inclination to help despite your very "vague" question. I understand that we in this forum came from several languages and our English just vary from all sides. For this you may pardon my long answer to a short question.]

Anyway, I hope this helps.

Be careful. Goodluck.
 
Old 03-16-2009, 01:00 PM   #4
palisetty_suman
Member
 
Registered: Feb 2007
Location: TX, USA
Distribution: fedora
Posts: 191

Rep: Reputation: 33
Thumbs up Hi

Thanks malek
 
Old 03-16-2009, 01:15 PM   #5
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285
There's also:

Code:
cat /dev/null > file
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
making a laptop drive empty?? linuxhippy Linux - General 3 01-10-2008 07:12 PM
large directory while it is empty Mrjas Linux - General 17 12-05-2007 03:35 AM
The postgresql data directory content in the pgsql directory is lost (empty data dir) kisembo Linux - Software 1 02-13-2006 02:11 PM
Large file upload - $_POST empty in PHP PsychosisNode Linux - Software 1 01-23-2005 08:32 AM
Mounting a large directory over NFS... Mountpoint is empty? Shade Linux - Networking 5 04-18-2004 09:29 PM


All times are GMT -5. The time now is 01:06 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration