- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: remove all files in a directory... but not del...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-17-2003 06:41 AM
тАО04-17-2003 06:41 AM
if so do i have to put the whole path name in the command?
the directory in question is /home/bobspod/jeepers
how do i empty jeepers?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-17-2003 06:43 AM
тАО04-17-2003 06:43 AM
SolutionFirst,
cd /home/bobspod/jeepers
rm *
Second,
cd /home/bobspod/jeepers
find . -exec rm -rf {} \;
The first method will trip over nested subdirectories, the second will remove the subdirs as well.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-17-2003 06:45 AM
тАО04-17-2003 06:45 AM
Re: remove all files in a directory... but not delete the directory
rm /home/bobspod/jeepers/*
or if their are thousands of files under that folder, then
find /home/bobspod/jeepers -print | xargs rm
Either way will leave the folder "jeepers" intact.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-17-2003 06:47 AM
тАО04-17-2003 06:47 AM
Re: remove all files in a directory... but not delete the directory
only the rm -rf will remove files and directories
the rmdir only removes a directory if there are no files inside
you want the rm *
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-17-2003 06:49 AM
тАО04-17-2003 06:49 AM
Re: remove all files in a directory... but not delete the directory
Yes either
rm /home/bobspod/jeepers/*
OR
cd /home/bobspod/jeepers
rm *
When you just use * then any files starting with "." will not be removed. So you may need to follow this command with
rm /home/bobspod/jeepers/.*
Note - you'll get squawks about not being anle to remove "." or "..", but that's OK as these are current & parent dir specifications & rm can't remove them
If there is dir structure below this dir then add -r to the command.
You remove dirs with the
rmdir
command
HTH,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-17-2003 06:49 AM
тАО04-17-2003 06:49 AM
Re: remove all files in a directory... but not delete the directory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-17-2003 06:51 AM
тАО04-17-2003 06:51 AM
Re: remove all files in a directory... but not delete the directory
cd /home/bobspod/jeepers
find . -path "./*" -prune -print | xargs rm -R
This will execute find on the current directory, but not descend into subdirectories displaying the names of each file or subdirectory. That output is piped into the xargs command which will run "rm -R" on the file/subdirectory names. See man "xargs" for it's benefits.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2003 06:53 AM
тАО04-18-2003 06:53 AM
Re: remove all files in a directory... but not delete the directory
This instruction will only delete files but not directories under /home/bobspod/jeepers.
If you want to get rid of everything under /home/bobspod/jeepers.
Then you only need to run something like:
rm -rf /home/bobspod/jeepers/* /home/bobspod/jeepers/.*
Regards,
Israel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2003 08:50 AM
тАО04-18-2003 08:50 AM