2

I'm creating a recycle-bin script in SH shell linux in three differant scripts, delete, trash and restore.

The first two scripts are working fine; 'Delete' moves the selected file to the recycle-bin while logging a text file called 'trashinfo' which shows the original path location of the file (to be later used in restore) and 'Trash' which removes everything in the recycle-bin.

The 'restore' script should take the logged path name gained in the delete script and return the file to its original location. I've spent more time than I'd like to remember on this and cant get the restore script to work properly!

Below is the script I've written, as far as I can make out I'm grepping for the filename variable in the text file that holds the pathname, eg 'restore testfile', this is then combined with the basename command, the testfile is then moved into the location thats been grepped and combined with the basename.

Anyone have any pointers on where I'm going wrong?

if [ "$*" != -f ]
then
path=grep "$*" /usr/local/bin/trashinfo
pathname=basename "$path"
mv "$path" "$pathname"
Oded
  • 463,167
  • 92
  • 837
  • 979

1 Answers1

0
path=$(grep "$*" /usr/local/bin/trashinfo)
pathname=$(basename "$path")
John Kugelman
  • 307,513
  • 65
  • 473
  • 519