Skip to content
Advertisement

Why copy command is not working when using file paths?

I’m having a problem with the copy command.

cp ../teste/env/test/x.tar ../../../teste2/file

The folders exist and also the file x.tar. When I start the script I’m on a different folder, so that’s why I make a ../ at the begining.

It keeps giving me this error: cp: cannot create regular file ‘../../../teste2/file’: No such file or directory

Worth to note that both teste and teste2 folders are on the same directory.

This is folder teste tree: teste tree

This is folder test2 tree: teste2 tree

Thanks a lot for your help!

Advertisement

Answer

From your comments I tried to rebuild the file tree you might have. I think the following call might work. You just miscalculated the relative paths.

cp ../teste/env/test/x.tar ../teste2/file

The relative path is always calculated from the current working directory meaning the folder from which you call the command.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement