Source path

what is the command for moving a file with it's original source path ?

??

when you "move" a file to a new directory the new directory will be the new path to access the file...
There is no such thing except backups... or you printing the content of the source directory before removing the file and documenting in the new directory...

ok that make much more sens for me. thank you :slight_smile:

:wink: I am trying to figure out what you are up to as a novice...
And try to help you achieve what can be...

If your idea is to "move" e.g. unused data file but that need to be put in the correct directory to be of some use... Lets say I have users squatting lots of space and I notice that the data has not changed for years but I need space on that filesystem, I would archive the content and gzip the archive, and save it in a hidden directory in the home directory of the user ( I can do that because I am root...) Now I let you struggle with the idea, it is a good idea to write a script to revert! commans you use for that? I use cpio (because Im familiar with it...) but you can use pax also.

What I am trying to do is to move selected file from root into the created by me folder and then restore it back to its original location by shell script. Point is that I know how to automate the creation of a folder( if it exists - do nothing) and coping a file but I have no idea how to keep the source path of the file before its moved so I can restore it back with another script :frowning: I simple don't know how to do it. I tried many web sites in order to find good answer and I couldn't find anything that I would understand.

Well I gave you enough to read: look at the man pages of cpio, find, pax, tar ...
I am not going to do the work for you, you will learn nothing that way...

I understand very well i got enough hints to crack it on :slight_smile:

---------- Post updated at 07:20 PM ---------- Previous update was at 06:15 PM ----------

This is what i came up with and it still doesnt work :frowning: any sygestions ?

while{

	if $1  == "del" {

		mv $2 /tmp/.trash/

		echo `pwd`+$2 > /tmp/.trash/$2+"_info.txt"

	} else if $1 == "trash" {

		if $2 == "-a" {

			rm /tmp/.trash/*

		} else {

			rm /tmp/$2

		}

      

	} else if $1 == "restore" {

		mv /tmp/.trash/$2 `cat tmp/.trash/$2+"_info.txt"`

	}

}

Ahem: whatever you use as a shell, this is not syntactically correct.

I could point out to you one error after the other, but honestly: you got nothing right, not even by a far shot. I suggest you get some introduction to shell scripting (there are lots of them on the net and there are lots of books dealing with the subject) and start reading. It is too time-consuming to explain this in a forum-thread.

I suggest you read such a source, try some example and if you have a specific question you come back and ask - we will be glad to help you.

I hope this helps.

bakunin

If I asked you to read the man pages of cpio... it was understood that mv is not to be used for what you want... and UNIX is not DOS, an rm is not reversible... so follow bakunin's advice and read those man pages, and come back explaining why you will use the command you chose... Then we can discuss the pertinence and give you advices and then comment the code you submit...