LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 04-16-2009, 05:46 PM   #1
fhsm
Member
 
Registered: Jan 2009
Posts: 51

Rep: Reputation: 17
Empty a directory


What is the easiest way to empty a directory from the command line without removing the directory itself?

Long version:
I want to put a couple of aliases in my .bashrc to empty these folders I've got from downloading data from a few lab instruments.
For example ~/lab/instruments/epic-32-random-char-folder/

I've found that deleting the whole folder is a mistake. It saves me a number of steps in the download if those long named dirs are already in place. The software that analyzes the results copies out of the directories but doesn't clear them. Long story short these dirs must be manually cleared of about a thousand files between each use.
 
Old 04-16-2009, 05:49 PM   #2
jay73
Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
rm *? If the folder does not contain any subdirectories, that is.

Last edited by jay73; 04-16-2009 at 05:50 PM.
 
Old 04-16-2009, 06:22 PM   #3
billymayday
Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
rm -rf ~/lab/instruments/epic-32-random-char-folder/*
 
Old 04-17-2009, 12:19 AM   #4
fhsm
Member
 
Registered: Jan 2009
Posts: 51

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by billymayday View Post
rm -rf ~/lab/instruments/epic-32-random-char-folder/*
Thanks!
 
  


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
rm: cannot remove directory `ff': Directory not empty blancs Linux - General 17 08-29-2011 02:47 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
Empty directory contents stefaandk Linux - General 1 08-22-2005 08:03 AM
deleting non-empty directory sadiboyz Linux - Newbie 2 04-21-2003 10:29 PM


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