So down :(
I've been at this for days and i'm starting to get so frustrated and down, like i'm never going to be able to do it. I am trying to. I've come so far. I'm going to explain the problem in as much detail as possible so it will be easier to give me the help i need.
There is a script which is created named del. This basically creates a recycle-bin in the $HOME of a user, and then renames the deleted file to a number (the number is incremented, e.g. the first file deleted is 1, the second is 2, the twentieth is 20 and so on). On deleting a file an .index file is updated within the $HOME/recycle-bin which contains the file name and the original files path, it is laid out like this:-
1 /home/user2/weblink
2 /home/user1/diary
3 /home/user/lightreading
Now, i have managed to get so far. I can have a user restore a file to its original directory by using the following script i've managed to put together:-
#! /bin/sh
awk '/'$1'$/ {
{printf("mv %s %s", $1,$2) | "sh"}
{printf("egrep -v '^%s' .index > .temp\n", $1) | "sh"}
{printf("mv -f .temp .index") | "sh"}
}' .index
This basically locates the desired filename to be restored, moves that file from the recycle-bin to its original directory along with its original name. I have then used egrep to update the .index file to .temp and then moved .temp to .index (e.g. renamed it). Now i have the following problems which i'm having so much difficulty with
1) The restore script only works if actually placed within the recycle-bin directory. I have attempted to use $HOME to solve this (e.g."mv -f $HOME/recycle-bin/.temp $HOME/recycle-bin/.index") but the moves still have issues with it. I have really tried to sort this one out but can't get my head around it.
2) My task also requires me to allow the user to find out what is in the recycle-bin (all of the files) through use of the '*' and also the versions of a file with a specified name.
3) I need to be able to take a file out of the recycle bin to either a specified path, or the directory the script is currently running in.
4) PERMINANTLY delete all files from within the recycle-bin via use of rm, the user must confirm this before they are actually delete though!
As i said, i've been working very very hard on this but i'm still unable to do these parts :( I know the answers to some of them are staring me in the face but i've just gone beyond the point where i continually try, i'm really going to break soon if i don't get this sorted. Any help would make me so happy.
There is a script which is created named del. This basically creates a recycle-bin in the $HOME of a user, and then renames the deleted file to a number (the number is incremented, e.g. the first file deleted is 1, the second is 2, the twentieth is 20 and so on). On deleting a file an .index file is updated within the $HOME/recycle-bin which contains the file name and the original files path, it is laid out like this:-
1 /home/user2/weblink
2 /home/user1/diary
3 /home/user/lightreading
Now, i have managed to get so far. I can have a user restore a file to its original directory by using the following script i've managed to put together:-
#! /bin/sh
awk '/'$1'$/ {
{printf("mv %s %s", $1,$2) | "sh"}
{printf("egrep -v '^%s' .index > .temp\n", $1) | "sh"}
{printf("mv -f .temp .index") | "sh"}
}' .index
This basically locates the desired filename to be restored, moves that file from the recycle-bin to its original directory along with its original name. I have then used egrep to update the .index file to .temp and then moved .temp to .index (e.g. renamed it). Now i have the following problems which i'm having so much difficulty with
1) The restore script only works if actually placed within the recycle-bin directory. I have attempted to use $HOME to solve this (e.g."mv -f $HOME/recycle-bin/.temp $HOME/recycle-bin/.index") but the moves still have issues with it. I have really tried to sort this one out but can't get my head around it.
2) My task also requires me to allow the user to find out what is in the recycle-bin (all of the files) through use of the '*' and also the versions of a file with a specified name.
3) I need to be able to take a file out of the recycle bin to either a specified path, or the directory the script is currently running in.
4) PERMINANTLY delete all files from within the recycle-bin via use of rm, the user must confirm this before they are actually delete though!
As i said, i've been working very very hard on this but i'm still unable to do these parts :( I know the answers to some of them are staring me in the face but i've just gone beyond the point where i continually try, i'm really going to break soon if i don't get this sorted. Any help would make me so happy.
