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.
Subscription
Categories
- HowTos (612)
- Linux Devices (40)
- Linux Diggs (620)
- Linux News (1541)
- Linux Videos (24)
Recent Posts
Blog Archive
-
▼
2007
(340)
-
▼
November
(39)
- HowTo: Strip directory path and filename suffix
- HowTo: Get the Filename Extension Only
- Tailf - watch the linux log file grows
- Fedora 8 with Enlightenment Window Manager
- HowTo: ScreenCasts & Desktop Records via Istanbul
- HowTo: Record Desktop Session via Byzanz
- Linux Scorched 3D Tank Game
- Linux Atomic Battle Tank Game
- HowTo: Display a Tree of Linux Processes
- Howto: 3 Easy Install Steps of Microsoft Fonts in ...
- Howto: Convert PDF to HTML/XML/PNG in Linux
- Livna Repository on Fedora 8
- Linux Action Flight Simulator Game
- Splitting and Merging Multiple Linux Files
- Sort Nth Position of Nth Column of a File in Linux
- Stop, Pause, and Continue A Linux Process
- File Creation without File Opening in Linux
- Concatenate Multiple Files in Linux
- Renaming Files in Linux
- Linux Power Consumption Analysis Tool
- Tail and Head Few Lines of Text Files
- Three Easy Steps for Opera on Fedora 8
- Alternative Search and Replace Tool
- Display Lines Beginning with a Given String
- Spell Check Files via Terminal - Install Howto
- Display Linux Session Jobs
- Get Linux Disk Space and Usage
- Change Linux RunLevels Howto
- Audacious - Install Howto
- Amarok - Howto Install
- Sun Java on Fedora 8 Install HowTo
- My Fedora 8 Diary
- Chikka on Kopete Messenger Howto
- Linux Files and Folders Local Copying
- Linux folders and directories recursive removal
- MailX - Mail Facility via Terminal
- Time zone values interpretation
- Retrieving Linux Standard Base and Distro Information
- Fedora Firstboot
-
▼
November
(39)
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