Find the answer to your Linux question:
Results 1 to 7 of 7
I am looking to uses two scripts, one to delete a file and one to restore it. I am trying to store the pathway it originally came from and use ...
  1. #1
    Just Joined!
    Join Date
    Jan 2009
    Posts
    3

    Linux delete and restore script

    I am looking to uses two scripts, one to delete a file and one to restore it.

    I am trying to store the pathway it originally came from and use that in the restore script. Any help would be great.

    So far i have

    Delete script

    path=ls|find ~ -name $1

    if test "$1" = ""
    then echo "Provide a filename"
    else mv /home/user1/$1 /home/user1/dustbin/
    fi

    Restore script

    restorepath=$path

    if test ! -n "$1"
    then mv /home/user1/dustbin/$1 $restorepath
    fi

  2. #2
    Linux Newbie
    Join Date
    Jul 2008
    Posts
    181
    Easy. Just use the complete pathname of your file, e.g.:

    Code:
    FILE=/my/file/to/delete
    mv $File /home/whatever/dustbin/$FILE

  3. #3
    Just Joined!
    Join Date
    Jan 2009
    Posts
    3

    Restore

    Yes i know how to delete it and send to dustbin

    However when in dustbin how to send back to its original location?

  4. #4
    Linux Newbie
    Join Date
    Jul 2008
    Posts
    181
    Quote Originally Posted by techproc View Post
    Yes i know how to delete it and send to dustbin
    No, you don't.

    The point is that you are using only the file name and discarding the rest of the path. As a consequence, you have no path to restore to.

  5. #5
    Just Joined!
    Join Date
    Jan 2009
    Posts
    1
    well i am looking for same thing

    delete and restore script,

    till now what i have is that i when deleting a file we should have some sort of full path name or relative path name saved like a log

    when we start restore script it looks into log file and move the to path in log file

    or we can move it to place we give a name of
    e.g
    restore <filename> /home/user/folder

  6. #6
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568
    Though i'm not sure about to write script . You may be interested in my project does the same.check my site from below.
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  7. #7
    Linux Guru
    Join Date
    Nov 2004
    Posts
    6,110
    I believe there is a Freedesktop spec for this already. It is already implemented in Gnome (or at least in Ubuntu 8.10) as I can see the option to restore. I think the Trash bin is now seperated into a files directory and an info directory to manage this.

    freedesktop.org - Specifications/trash-spec

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...