In Terminal (using bash and tcsh) cp -r copies the contents of a folder instead of the folder if the folder argument has a / at the end.
Given the following structure:
folderA
|-fileA
|-fileB
The following command copies fileA and fileB to destination instead of copying folderA to the destination:
cp -r folderA/ destination
So it acts as
cp -r folderA/* destination
This is super annoying because by default completion in tcsh adds a / at the end of the folder, so I always end up having to clean up if I forget to delete the / at the end. This behavior is different from every other *nix I've worked on.
Is there any way to change this and make cp -r folderA/ copy the folder instead of its contents?
cp
- jondavidjohn.com/blog/2012/09/linux-vs-osx-the-cp-commandcp
commands do not act the same as the second would not copy hidden files and directories in folderA, while the other does.cp foo bar
, I'll either get bar/ as a clone of foo (if bar/ didn't already exist), or bar/foo/ (if it did.) It's a little confusing. On the other hand, if I docp foo/ bar
then the results are consistent.