Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use the rm command in CentOS to move files to the Recycle Bin

Shulou Source: shulou.com Published: 2022-06-01 09:29:12 09月11日 Update

This article introduces the knowledge of "how to use the rm command in CentOS to move files to the Recycle Bin". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Here are the methods:

The principle is to create a hidden folder ~ / .trash under the user's home directory as the garbage recycling bin.

The code is as follows:

Mkdir-p ~ / .trash

Vi / .bashrc

Then write the following code into ~ / .bashrc and save it.

The code is as follows:

Alias rm='trash'

Alias rl='trashlist'

Alias ur='undelfile'

# replace rm instruction to move files to ~ / .trash/

Trash ()

{

Mv $@ ~ / .trash/

}

# display the garbage list in the Recycle Bin

Trashlist ()

{

Echo-e "33 [32m / cm] = Garbage Lists in ~ / .trash/ = = 33 [0m"

Echo-e "\ a33 [33m----Usage-33 [0m"

Echo-e "\ a 33 [33m-1-Use 'cleartrash' to clear all garbages in ~ / .trash!! 33 [0m"

Echo-e "\ a33 [33m-2-Use 'ur' to mv the file in garbages to current dirt pollution 33 [0m")

Ls-al ~ / .trash

}

# retrieve the corresponding files in the Recycle Bin

Undelfile ()

{

Mv-I / .trash/$@. /

}

# empty the Recycle Bin

Cleartrash ()

{

Echo-ne "\ a33 [33m benchmark clear all garbages in ~ / .trash, Sure? [YBO] 33 [0m"

Read confirm

If [$confirm = ='y'-o $confirm = ='Y']; then

/ bin/rm-rf ~ / .trash/*

/ bin/rm-rf ~ / .trash/.* 2 > / dev/null

Fi

}

Refresh the environment configuration below the command line to take effect:

The code is as follows:

Source / .bashrc

"how to use the rm command in CentOS to move files to the Recycle Bin" ends here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: The Recycle Bin files code commands contents garbage more knowledge practicality learning and then principles dilemmas realities situations heads of households instructions folders articles methods Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Linux Shulou Technology MariaDB macOS