Glam Prestige Journal

Bright entertainment trends with youth appeal.

cp -av /home/jake/transit/scalaProjects/scalaML/src/main/scala /home/jake/project/__workspace/scalaProjects/scalaML/src/main/scala
cp -av /home/jake/transit/scalaProjects/scalaML/src/test/scala /home/jake/project/__workspace/scalaProjects/scalaML/src/test/scala

The first line copies to /src/main/scala

BUT

the second copies to /src/test/scala/scala

I am on Ubuntu server 16.

I am sure I am missing something, but I am confused. ANy help would be appreciated

1

2 Answers

Consider cp a b/c.

  1. If c doesn't exist (and b does), it will be interpreted as a name for the copy of a, so you will end with b/c.

  2. On the other hand if c does exist and it's a directory, it will be interpreted as a path where to place a under the unchanged name a, so you will end with b/c/a.

I guess in the beginning /home/jake/project/__workspace/scalaProjects/scalaML/src/main/scala doesn't exist, there's only /home/jake/project/__workspace/scalaProjects/scalaML/src/main/.

Your first command creates scala acting as (1). It may be somewhat confusing because you have scala in place of a and c, so it's not obvious that some trivial renaming takes place (from scala to scala). Then the second command acts as (2).


This command will work as your first one, regardless if the target scala exists, if only /home/jake/project/__workspace/scalaProjects/scalaML/src/main/ exists:

cp -av /home/jake/transit/scalaProjects/scalaML/src/main/scala /home/jake/project/__workspace/scalaProjects/scalaML/src/main/

But if /home/jake/project/__workspace/scalaProjects/scalaML/src/main/ doesn't exist and /home/jake/project/__workspace/scalaProjects/scalaML/src/ does, your scala will be placed there under the name main. This is behavior (1) again.

To get rid of this ambiguity use -t:

cp -av /home/jake/transit/scalaProjects/scalaML/src/main/scala -t /home/jake/project/__workspace/scalaProjects/scalaML/src/main/

This makes cp interpret main as a directory where you want to place scala. No renaming will take place. If /home/jake/project/__workspace/scalaProjects/scalaML/src/main/ doesn't exist, cp will throw an error.

1

I have found the problem and solution. A hidden file remained in the directory even though I had attempted a full delete fo the directory previously (rm -rf).

This file .fuse_hidden was created by the file system because an SFTP server session still held a link to the file. (I had previously opened a file in that directory via mobaxterm).

Closing down the session on my mobaxterm terminal that had opened the file, led to the removal of the hidden file and then all else worked fine. Note that closing down the file I had opened remotely was insufficient to resolve the problem.

see here for a better explanation

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy