Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
tar -cf /Users/Files/myfile.tar /Users/Files/

I am basically trying to create a tar containing the contents of User/Files and create it in the folder of the contents.

I can only execute this process in one line, so I cannot cd before.

share|improve this question

tar -cf myfile.tar /Users/Files/ && mv myfile.tar /Users/Files/
One line right? :D

You are archiving a folder and writing in it at the same time. That's really wrong and thankfully it does not work.

Since you are using ssh to pass this command you have most likely use something like this:

ssh <user>@<host> -- tar -cf myfile.tar /Users/Files/ && mv myfile.tar /Users/Files/

But in this example the && works between ssh and mv and not tar and mv. Use this instead:

ssh <user>@<host> -- "tar -cf myfile.tar /Users/Files/ && mv myfile.tar /Users/Files/"

By the way, The tar: Removing leading '/' from member names warning you may see is only a warning, not an error due to an absolute path.

share|improve this answer
The file doesn'¨t seem to be moved when executing a ls right aftr – George Aug 5 '13 at 11:53
it works fine on my debian :/ what system are you under? You can replace && by ; but both are supposed to work. Why is you question tagged under ssh btw? – ycouble Aug 5 '13 at 12:23
since im using ssh :P – George Aug 5 '13 at 14:26
Then tell it in your question body! I will edit my answer then – ycouble Aug 5 '13 at 14:34
I think I found the reason it didn't work, it was because of file permissions... – George Aug 5 '13 at 22:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .