Restoring a file

I'm new to Unix and have just wrote a little program to move files to a recycle bin (a Directory i created) and restore them. The problem is that i need to keep track of all the full filenames so that i can restore them to the right place. I did this by creating a file called delreg and putting the full filenames in it.
But i don't know how to write the full filename to the file or for that matter how to restore the file. My code so far looks like this
pwd >> /home/zoolz/delreg
$1 >> /home/zoolz/delreg
But this code only puts it on 2 lines.
Please if anyone can help it would be great because i seem to be banging my head against a wall

Not sure if I understood your problem?! Give example. How do you identify the files that will move to the bin?

Not sure about you requirements, but are you taking care of these things:

(a) the recycle bin should ideally be able to store multiple files with same names (see the RecycleBin on Windows)

(b) If I understand right you are trying to store "pwd" as the location where the file will be finally restored. Careful here, because while using the rm command I can specify a pathname myself. i.e. being in the directory "/home" I can delete a file like this "rm /home/user10/testfile.txt". Obviously you dont want to restore testfile.txt to "/home"

Check this out.

This will put the filename into a hidden file.

#! /bin/ksh
# ./delreg file

[ -z "$1" ] && echo "Need a file to delete" && exit 1 || FILE="$1"

# delreg is in the directory DIRNAME
DIRNAME=`pwd`

#  FILE will ibe either one of the following
#+ DIRNAME/FILE
#+ or /FILE
#+ //FILE will evaluate to /FILE

if [ -f "$DIRNAME/$FILE" ] ; then
echo "$FILE@@$DIRNAME/$FILE" >> /tmp/.delreg.list
#mv $FILE /tmp
exit 0
fi ;

if [ -f "/$FILE" ] ; then
echo "$FILE@@/$FILE" >> /tmp/.delreg.list
#mv "/$FILE" /tmp
exit 0
fi ;
echo "$1 is not a valid file"
[~/temp]$ ./delreg.ksh /etc/passwd
[~/temp]$ ./delreg.ksh /etc/pass
/etc/pass is not a valid file
[~/temp]$ ./delreg.ksh /etc
/etc is not a valid file
[~/temp]$ ./delreg.ksh delreg.ksh
[~/temp]$ cat /tmp/.delreg.list 
/etc/passwd@@//etc/passwd
delreg.ksh@@/home/vino/temp/delreg.ksh

The @@ is delimiter. The pattern goes as $FILENAME@@$LOCATION

This script does the delete part. You will have to extend on this script to recycle the file.

I dont know the behaviour of

./delreg.ksh delreg.ksh

I think it should move itself to /tmp

Uncomment the # in front of the mv statement.

vino

Thanx guys that got me out of a jam