Bash - Trash Command

Make a trash command in bash, which sends files to a recyle bin, instead of deleting them.

For the solution, we will separate each task into separate commands, and then combine then into one trash command.

Move Files Into Trash Folder

Make Trash Folder

In the default directory, we will make a directory for storing trash, then a directory for storing logs.

$ mkdir ~/trash ~/logs

Move Items to Trash

This will move a file to trash. We will make this configurable later.

$ mv file_name.txt ~/trash

Log Actions in a File

Add a Timestamp

This will return a timestamp in the format: HH:MM:SS.

$ date | cut --delimiter " " --fields 4
13:37:13

Log Files

$ date 1>> timestamp

https://help.codea.live/raspberry-pi-hosting/challenges#challenge-make-a-trash-command

[Bonus] Make It a Script

Add Script to PATH

$
$ mkdir ~/bin
~/bin/trash
$FILE_NAME=""