473,386 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to empty the directory?

9
how to empty the files in the directory without removing the directory itself?
I want to have it force delete all the file in the dir
so
I tried using

rm -fR [directory]

but it delete my directory as well.

pls advise.
May 24 '11 #1
4 2109
Banfa
9,065 Expert Mod 8TB
Have you tried

rm -fR [directory]/*
May 24 '11 #2
sicarie
4,677 Expert Mod 4TB
Alternatively, you can cd into the directory

cd /path/to/dir; rm -rf *

As you're currently in the dir with the above, it won't be able to remove the directory
May 24 '11 #3
numberwhun
3,509 Expert Mod 2GB
Alternatively, you could do the following:

rm -f directory/*

That will remove everything in the directory, but leave the directory in tact.

Regards,

Jeff
May 24 '11 #4
chez
9
thx all for the help
It works with that.
May 25 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Tung Wai Yip | last post by:
Can I add empty directory using zipfile? When I try to add a directory it complains that it is not a file. tung
1
by: Fuzzyman | last post by:
I have created a set of classes that will profile a file structure and record all changes as a simple markup and single zipfile of all new/modified files. I can't get the zipfile module to archive...
2
by: Danny Miller | last post by:
Hi there, I'm facing a problem that is driving me nuts. The scenario is as follows: 1) Create an empty directory structure e.g. C:\Dev1\TestWebApp 2) Map a virtual directory e.g. TestWebApp...
3
by: Bill nguyen | last post by:
Is there a quick way to determine if a directory is empty. Directory.Getfiles() doesn't tell me how many files without having to loop thru the list. Thanks Bill
0
by: Markus Ernst | last post by:
Hi In an application installed with PHP5 it looks like ftp_nlist() returns false if the directory is empty, instead of an empty array as it should according to the manual. On the original server...
5
by: ajay m | last post by:
hi, i am new to perl I am looking for a simple script to delete non empty folder. Remove Directory and File(s) plz help me...
6
by: Raman | last post by:
HI All, Please help me understand, Is there any standard C -library function available that can delete non-empty the directory tree. Thanks and Regards, Raman Chalotra
1
by: loial | last post by:
Trying to use ftplib.FTP.nlst() method to list the files in a directory on a FTP server. It works fine except when there are no files in the directory. Then it gives the error ...
1
by: sethupnr | last post by:
hi i'm creating an FTP client using java.I hav one question,how can i delete a non empty directory in a remote server. I'm using common net FTPClient . Plz guide me. thanks in advance
1
by: bohar | last post by:
i have create directory for gallery and stores images in gallery folder but i am unable to delete directory.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.