Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

delete all files in current directory

Posted on 2010-01-06
6
Medium Priority
?
311 Views
Last Modified: 2012-05-08
Is a command you can issue that will delete every file in the current directory only?
0
Comment
Question by:PeterErhard
6 Comments
 
LVL 3

Expert Comment

by:infochandru
ID: 26188673
Hope this wil help you

     rm -rf *
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 total points
ID: 26188684
Rather use
rm -f *
rm -r will also delete all subdirectories recursively, which is obviously not desired!
wmp
 
0
 
LVL 48

Expert Comment

by:Tintin
ID: 26188696
If you really want to be pedantic and *only* include files, then

find . -type f -maxdepth 1 | xargs rm
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:PeterErhard
ID: 26188727
Thanks guys.

So, just to confirm:

If I'm in the "/home /admin /_processed_stats" directory and run rm -f * it will only delete the files within that directory and nothing else?
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 26188746
Yep!
0
 
LVL 2

Expert Comment

by:BrianWe
ID: 26188900
For goodness sakes be careful with spaces when using rm -f ;)

rm -rf /usr/local /bin

for example will remove /usr/local AND /bin ;) not /usr/local/bin ;)
and Tintin's solution is the best, because it won't remove directories, just files.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question