Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report