Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 07-29-2011, 12:22 AM   #1
LQ Newbie
Registered: Dec 2010
Posts: 28

Rep: Reputation: 0
Delete a subfolder ABC from main Project Folder

Dear all,

I want to delete a subfolder ABC in a main Project folder Globe.
It occurs in many subfolders.

It is very hectic to search and issue an rm -rf ABC command.

I need to make a script for that .

Can anyone tell me how to make this

Old 07-29-2011, 01:09 AM   #2
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,198

Rep: Reputation: 2310Reputation: 2310Reputation: 2310Reputation: 2310Reputation: 2310Reputation: 2310Reputation: 2310Reputation: 2310Reputation: 2310Reputation: 2310Reputation: 2310
Start by reading up on 'find'
Old 07-30-2011, 05:11 PM   #3
Registered: Jan 2009
Location: New England
Distribution: Arch Linux
Posts: 719

Rep: Reputation: 103Reputation: 103

find /path to parent/folder/ -type d -and -iname Folder-Name -exec stat {} \;

Validate they are the correct folders. Then change stat to rm -fr.
Old 07-30-2011, 05:21 PM   #4
Senior Member
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 476Reputation: 476Reputation: 476Reputation: 476Reputation: 476
@ Reply

Hi there,

You can also try the following commands:

find / -name name_of_the_folder -print
The above command will print the location where that folder ABC has been created

you can delete the folder with the same command but with little modification:

find / -name name_of_the_folder -print -delete
I hope this helps.
1 members found this post helpful.
Old 07-31-2011, 11:52 PM   #5
LQ Newbie
Registered: Dec 2010
Posts: 28

Original Poster
Rep: Reputation: 0


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
Show folder and only one subfolder using ls in command line Drigo Linux - Newbie 4 07-14-2011 12:56 PM
Compare string (capitol letters) abc to ABC Willy Fog Linux - Newbie 4 09-17-2009 11:36 AM
How to set linux environment variable like (With DOT in the string) super_hill Linux - General 1 12-03-2008 07:37 PM
how to run a script on subfolder file in a folder saggi_sam Linux - Newbie 5 07-13-2005 05:04 AM
main.c vs project.c liguorir Programming 6 05-24-2004 07:49 AM

All times are GMT -5. The time now is 12:39 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration