I am trying to understand linux and working through some tutorials. One states that I can copy files to the current directory by using a cp -a command with a relative pathname such as
cp -a ../somedir/. It fails each time I run it. Is the syntax incorrect?
I tried the man page, but it didn't seem to find anything that answers my question.
2 Answers
cp -a ../somedir/. is wrong. The general syntax is
cp source targetYou only specified one argument. To copy something to current directory, you can run
cp ../somedir .Note the space before the dot. . is shorthand for current directory. .. is shorthand for parent directory.
You can say:
cp -a ../somedir .if you want to copy the folder it self with its content
Or you can say
cp -a ../somedir/* .
If you want to copy the content of the folder.
the -a option will try to clone the same file structure with the same file tree to the new location