My own removing command using shell script

helo ,

Yesterday and today , I started studying shell script .. Mr . Chnadrashekar sir started some basics on

SHELL SCRIPTING .. !!  then he gave a small  task such that , to make own removing command ..

when we remove a file , i.e deleted file will go to a another directory named RECYCLE .. (like trash) it will have back up of that deleted

file .. This will prevent data loss , when files deleted any other user other than U 🙂

and also , it will store in folder in RECYCLE with date, time as folder name  (TIMESTAMP) .. by this we can come to

when file was deleted 🙂


mkdir RECYCLE >/dev/null 2>&1
echo “program name :$0”

mkdir “`date +%d:%m:%y:%H:%M`” >/dev/null 2>&1

if [ $# -lt 7 ]; then
cp $1 $2 $3 $4 $5 $6 “`date +%d:%m:%y:%H:%M`”  && rm $1 $2 $3 $4 $5 $6 >/dev/null 2>&1
cp -r “`date +%d:%m:%y:%H:%M`” RECYCLE && rm -r “`date +%d:%m:%y:%H:%M`” >/dev/null 2>&1
exit 0
echo ” \n WARNING : u are not allowed to delete more than $# at a time !!!!!!! \n ”
exit 1


and by this script u ll have back up at current directory where u are deleting files !!

so u can make ur own destination directory for RECYCLE (for backups)

i.e I will back up files in my media !! so i have to give

mkdir /media/70CCFA76CCFA35C6/”`date +%d:%m:%y:%H:%M`” >/dev/null 2>&1

it will store in /media/70CCFA76CCFA35C6 … change ur destination path to all lines 🙂

after that alias ur script to ‘rm’ command


alias rm=”/home/sathia/Desktop/shellscripting/”

Then save your files !!!!

This is my first shell scripting program !!!!




About sathia

Web developer at cloudmint
This entry was posted in ubuntu. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s