LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Two scripts, delete and restore (https://www.linuxquestions.org/questions/linux-newbie-8/two-scripts-delete-and-restore-4175526398/)

highland 11-24-2014 08:05 PM

Two scripts, delete and restore
 
Hello, just wondering if anyone on here can help me. I'm very very new to linux, and i am currently using VM Player to run an ISO which has a GUI and seems fairly simple. I am trying to create two scripts, one to delete a file (basicly move it some kind of recycling bin where it can be restored) And a restore script, to put that file back into its original directory. This seems fairly simple however i find myself scratching my head when it comes to scripting. Any help would be great, thanks!

jailbait 11-24-2014 08:18 PM

Welcome to linuxquestions.


Quote:

Originally Posted by highland (Post 5274537)
one to delete a file (basicly move it some kind of recycling bin where it can be restored)

That can be done with the mv command.

Look at:
man mv

Quote:

Originally Posted by highland (Post 5274537)
And a restore script, to put that file back into its original directory.

That can be done with the cp command.

Look at:
man cp

----------------------------
Steve Stites

highland 11-24-2014 08:29 PM

thanks, how would i go about actually creating these scripts, so that in console i could type for example del <pathname> the file will end up in the dustbin in a retrievable state, and restore <filename> back to where it was? I'd like ideally for the restore script to add .back to a restored file if there is a file in there already with the same name

jailbait 11-24-2014 09:10 PM

You create a script by creating a text file with a text editor and then make that file executable. The text file is a series of commands.

Here is a step by step tutorial on how to do that:

http://linuxconfig.org/bash-scripting-tutorial

----------------------------
Steve Stites


All times are GMT -5. The time now is 07:48 PM.