nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Linux Recursively Delete Subdirectories

This is a discussion on Linux Recursively Delete Subdirectories within the Linux software forums, part of the Linux Getting Started category; To recursively delete subdirectories and all files, use the following syntax: Code: rm -rf /path/to/directory For example, recursively delete subdirectories ...


Go Back   nixCraft Linux Forum > Linux Getting Started > Linux software

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 04-22-2008, 01:50 AM
raj raj is offline
Contributors
User
 
Join Date: Jun 2005
Location: Hyderabad
Posts: 148
Rep Power: 4
raj is on a distinguished road
Default Linux Recursively Delete Subdirectories

To recursively delete subdirectories and all files, use the following syntax:
Code:
rm -rf /path/to/directory
For example, recursively delete subdirectories /home/test/data, enter:
Code:
rm -rf /home/test/data
You can also find all *.bak in many subdirectories and delete them:
Code:
find . -type f -name "*.bak" -exec rm -i '{}' \;
find . -type f -name "*.bak" -exec rm -f '{}' \;
The -i option prompt before any removal and the -f option ignore nonexistent files, never prompt for anything.

Be careful examples may result into data loss, use them carefully don't blame me for data loss.
__________________
Raj
Linux rulz.
I have never turned back in my life ; I shall not do so today.. haha
Reply With Quote
Sponsored Links
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Shell script to restructure folders recursively kalt Shell scripting 2 10-26-2007 12:47 AM
Delete all tables mysql under Linux jerry Databases servers 1 06-09-2007 05:50 PM
Linux find and delete files cbzee Linux software 4 12-20-2006 12:01 PM
delete directory linux chiku Linux software 4 07-22-2006 06:56 PM
copying files from subdirectories kavi Shell scripting 2 09-18-2005 12:37 AM


All times are GMT +5.5. The time now is 05:46 AM.


Powered by vBulletin® Version 3.7.3 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36