Emergence in Games

A Best Games Review Blog

12464 - Emergenceingame

Delete multiple subdirectories on Linux with CMD . command

A quick way to help you delete multiple subdirectories with just a single CMD command line instead of using the rm command many times on Linux, this is a very useful way for those of you who are lazy to delete each folder on your system, refer to Read below to see how to do it

Normally when you want to delete many subdirectories in a large directory on Linux, you will have to use the command rm many times. However there is a faster way to do this. For computer users, there are many ways to delete files and folders on their computer such as using Ccleaner or creating .bat files to delete files and folders. On Linux, to delete a directory or subdirectories contained in it, we can use the Command Prompt command, also known as the CMD command.

delete many files on linux

Delete multiple subdirectories on Linux with CMD . command

For example, we have a folder named htg contains 5 subfolders. To delete 3 of them, we would normally use the command rm 3 times.

xoa nhieu thu muc con tren linux bang lenh cmd 1 - Emergenceingame

This process can be shortened by combining 3 rm statements.

To do this, type the following command and press Enter (rename the folders to the ones you want to delete on your computer).

rm -r ~/Documents/htg/{done,ideas,notes}

Each word in brackets is an extension, followed by the preceding part (~/Documents/htg/).

The above command can be divided into ~/Documents/htg/done, ~/Documents/htg/ideasand ~/Documents/htg/notesare the paths to the directory to be deleted.

After typing the command, all 3 of these subdirectories have been deleted (illustrated below).

xoa nhieu thu muc con tren linux bang lenh cmd 2 - Emergenceingame

Part -r added to the rm statement when you want to delete a directory, not just a file. If the above command does not have the –r, The system will give an error that cannot delete the folder.

xoa nhieu thu muc con tren linux bang lenh cmd 3 - Emergenceingame

If all 3 subfolders you want to delete are empty, you can use command rmdir as follows:

rmdir ~/Documents/htg/{done,ideas,notes}

If not all the subfolders you want to delete are empty, the system will only delete the wide folders and give an error that can’t be deleted for non-empty folders.

xoa nhieu thu muc con tren linux bang lenh cmd 4 - Emergenceingame

Above, Emergenceingames.com has just instructed how to delete multiple subdirectories using just one command on Linux. This saves you time instead of having to use the delete statement multiple times with each directory.

https://thuthuat.Emergenceingames.com/xoa-nhieu-thu-muc-con-tren-linux-bang-lenh-cmd-12464n.aspx
Via: howtogeek

Related keywords:

delete folder on linux using cmd

delete folder on linux with cmd, delete folder in bulk on linux,

Source link: Delete multiple subdirectories on Linux with CMD . command
– Emergenceingames.com

Leave a Reply

Your email address will not be published. Required fields are marked *