Today I was thinking to myself; I have to write a program to share today. I set myself the goal of writing it, so I sat down and thought about what I would like to create. I went through my thoughts and knew 2 things about myself. I love safety and security. I had already created thus far a password maker. I was proud of that project. Today, I wanted to do something similar in Python 3, but it turned out to be contrary to what I wanted to do.
I got scripting in Python, creating the intro, the open and closing of files. However, the crucial code I wished to execute, I couldn’t find the means to do it after gaining the users input. Not using the os.method or any other method in fact to invoke the bash script desired.
So I changed from Python scripting to Bash scripting. I had to change a bit about my project to get it to work, but what occurred was a very hacky, but cool program that does what I wanted it to do.
To ***SECURELY DELETE FILES***
You see, to remove a file via the command rm -f doesn’t do the erasure of the file justice or completely. It is just sitting there in the background, just waiting for an apt forensic specialist to just come along and pick it out from the other 0’s and 1’s.
I did a bit of research and it turns out Debian has a cool function called Shred. The shred function is very cool. And in fact, you can call that shred function within the script within one line in the terminal. But where is the fun in that!!
The script I wrote in Bash provides you with a nice heading provided by figlet, then a welcome message, followed by a blank area to input the file you wish to erase. Then with your selection shred goes to work removing its existence from your computer.
And before too long you are met with an exit message and you are back in your terminal. As far as graceful coding goes, it is not the prettiest script to look at, but the function it delivers is absolutely fine. I would rather a functioning script that looks spot on during operation, than have to labour too much over aesthetics for someone who wants to read my code.
Function is important to me, and you can achieve the function in whatever way works. If you would like to clone the repository, or download it via zip – go to:
The instructions are in the README.md. All you have to do is:
chmod +x securedelete.sh (This gives it executable power via the ./ )
Then to execute:
And that’s it. As far as Windows or Mac systems using bash in the terminal or command prompt, you will have to do your research there I’m afraid. I’m not sure how that would work for Windows in particular. I know the Mac has bash within the terminal that you can utilise or maybe you can install it with brew. I can’t remember.
Anyhow, I hope you enjoy secure delete. I am proud that I was able to create a good program tonight that is useful many times over. It is a nice, simple command line tool.
Have a good night.