The Trash Command

Almost every beginner in linux/unix systems at some point in time has messed up because of the infamous rm command. For those who don’t know, the rm -rf command is user to delete any given directory/file. Now while it doesn’t sound all that bad, it is really unforgiving and could really mess things up for someone who doesn’t know what they are doing. As I mentioned in my previous post, I worked on a linux and operating system fundamentals course this week. I learnt a lot of new things starting from what is the job of an operating system to learning shell scripts to execute command and automate stuff as a system admin. I found shell scripts to be really interesting, and that motivated me to work on this trash command idea. The motivation behind this was to figure out a way to make a command that is more forgiving than the rm command. So I came up with a suite of trash commands.

This suite includes the following commands:
> trash-add : This command adds the given file to the trash can directory
> trash-remove : This command removes the given file from the trash can and the system permanently
> trash-restore : This command restores the given file in the specified directory .
> trash-empty : This command empties the trash can and removes all the contents of the trash can permanently from the trash can and from the system.
> trash-show : This command shows all the contents of the trash can in a neat formatted way.

  • The trash-add command :
    This command is the core of all the functionalities of the trash can. The idea behind this function was a really simple one. If the user doesn’t have a trash can then make one, or
    else add the requested file/directory to the existing trash can.

The above code snippet shows the trash-add command’s shell script. The code for all these commands along with the documentation and instructions to set up can all be found on my
Github Repo :

This was my first project and experience with shell scripts and I am very happy with this effort. I plan to make this better by adding on to the functionalities, and making it better. I hope this helps everyone who is interested and looking to start out with shell scripts.

Linux and Operating Systems Fundamentals

Learning to work with linux is one of the few extremely essential skills that every programmer should be equipped their skillset with. I recently began working on a course focused towards linux and other unix based operating systems. I believe that this course has some very interesting insights and I plan to note all of them down as I proceed with the course. While doing so, I will also share them here every week, so that these insights could help every beginner out there, trying to figure out where and how to start.