I have been noticing with all my old linux blog entries that most other simple commands are being covered and taken from a single blog entry. These linux commands have not been pinpointed by definition and usage samples, why such commands has been issued and bypassed from detailed explanations from this linux blog site.
How to delete multiple directories and folders recursively?
How to create multiple folders simultaneously?
How to delete multiple folders interactively and recursively?
Here are few basic samples of simple commands that has not been a blog entry topic here.
Read the DISCLAIMER, be careful on using these rm commands.
Let us start working into the linux temporary folder /tmp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# cd /tmp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Create multiple directories or folders simultaneously
The long way:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# cd /tmp
# mkdir tmp1
# mkdir tmp1/tmp2
# mkdir tmp1/tmp2/tmp2B
# mkdir tmp1/tmp3
# mkdir tmp1/tmp3/tmp3B
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The short way:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# mkdir tmp1 tmp1/tmp2 tmp1/tmp3 tmp1/tmp2/tmp2B tmp1/tmp3/tmp3B
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Interactive rm deletions do screen prompts before proceeding to any rm command executions like shown below.
In Fedora and RedHat, by default, rm command prompts before any proceeding to rm executions.
Delete multiple folders recursively and interactively.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# cd /tmp
# mkdir tmp1 tmp1/tmp2 tmp1/tmp3 tmp1/tmp2/tmp2B tmp1/tmp3/tmp3B
# rm -ri tmp1
rm: descend into directory `tmp1'? y
rm: descend into directory `tmp1/tmp3'? y
rm: remove directory `tmp1/tmp3/tmp3B'? y
rm: remove directory `tmp1/tmp3'? y
rm: descend into directory `tmp1/tmp2'? y
rm: remove directory `tmp1/tmp2/tmp2B'? y
rm: remove directory `tmp1/tmp2'? y
rm: remove directory `tmp1'? y
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As you can see, rm descends to folders recursively and prompts everytime a folder deletion is about to occur.
Force delete multiple folders recursively without any folder deletion prompts and confirmations.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# mkdir tmp1 tmp1/tmp2 tmp1/tmp3 tmp1/tmp2/tmp2B tmp1/tmp3/tmp3B
# rm -rf tmp1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Alternatively, here's another long approach of deleting folders and subdirectories recursively
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# cd /tmp
# mkdir tmp1 tmp1/tmp2 tmp1/tmp3 tmp1/tmp2/tmp2B tmp1/tmp3/tmp3B
# find /tmp/tmp1/ -type d -exec rm -rf {} \;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Another basic way to delete multiple but separate folders
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# rm -rf folder folder2 oldfolder*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You might be interested with the CONSIDERATION details from the bottom page too.
HTH.
Categories
- HowTos (611)
- Linux Devices (39)
- Linux Diggs (620)
- Linux News (1541)
- Linux Videos (24)
Recent Posts
Blog Archive
-
►
2008
(2302)
-
►
October
(140)
- Linus Torvalds on Linux Distributions
- AMD to Spin off Manufacturing Operations
- MySQL cofounder David Axmark leaving Sun
- Mono to contribute back to CLI; Microsoft says it ...
- Monitor your network with GroundWork Monitor Commu...
- The LXF Guide: Write a Perl module
- 8 Best First-person Shooter Games for Linux
- AppDeploy Community Launches Free Windows Installe...
- Ubuntu Tweak - Sneak Peak at Latest Version!
- POS stack targets Linux netbooks
- RIP LinuxWorld
- Firefox extension blocks dangerous Web attack
- Wikia co-founder to speak at linux.conf.au
- Wikia co-founder to speak at linux.conf.au
- Look Ma, No ‘X’
- Look Ma, No ‘X’
- Forget the damn Linux netbooks. Can Windows replac...
- Forget the damn Linux netbooks. Can Windows replac...
- Amarok 2.0 Beta 2 was released
- 6 Years As A Professional Software Developer
- Amarok 2.0 Beta 2 was released
- 6 Years As A Professional Software Developer
- Distribution Release: EnGarde Secure Linux 3.0.21
- Torvalds talks about his brand new blog
- Become a multimedia pro with the Vector Linux Mult...
- Linux Robot - Watch This Space
- Distribution Release: EnGarde Secure Linux 3.0.21
- Torvalds talks about his brand new blog
- Become a multimedia pro with the Vector Linux Mult...
- Linux Robot - Watch This Space
- Linux-Based E-Voting In Brazil
- Is .NET on Linux Finally Ready?
- Linux-Based E-Voting In Brazil
- Multi-core networking stack ported to PowerPC
- Google rev's photo editor for Linux
- Project releases version 2.0 of open source .Net
- One more 2.6.27 prepatch
- Stallman vs. Clouds
- How to Create and Use a Password Reset Disk in Win...
- OpenOffice.org Grows Up
- 45+ Sources and Sets of Photoshop Custom Shapes
- Clean up your filesystems with fslint
- NPX-9000 UMPC is inexpensive but underpowered
- Will Chrome Find a Home With SaaS?
-
►
October
(140)
Wednesday, November 14, 2007
Linux folders and directories recursive removal
Subscribe to:
Post Comments (Atom)
ILoveTux - howtos and news | About | Contact | TOS | Policy


0 comments:
Post a Comment