annoying unwanted behavior

afflictedd2

Registered
I dont' get why the unix underneath mac, copies files with in a folder when I do the following command, and why it copies the folder without the '/'. I just want it to copy the folder, and if I wanted to copy the files I'd explicitly would say InputX/*. I often forget to remove the '/' when I'm autocompleting folder names.

cp -r InputX/ /Users/Naix/Project/Compare

Is there a way to change this annoying unwanted behavior?

TEd
 
You're using the -r switch. That means "recursive." That means the folder, and all the files in the folder, and all the folders in the folder, and all the files in that folder in the folder, ad infinitum.

What do you mean when you say you only want to copy the folder? Do you mean copy a folder with items in it to another location, but only the folder itself and not the files within, effectively creating just an empty folder with the same name somewhere else? If so, why not just 'mkdir [foldername]'?

A forward slash is an invalid character to have in a file or folder name in UNIX... for example, the following two commands do the exact, same thing:

mkdir test
mkdir test/

Can you explain in greater detail what you're trying to do?
 
basically in unix machines I've worked previously

This:
mv -r directory/ ../xlocation

is the same as:

mv -r directory ../xlocation

in MacOs, they are not the same thing.
I would like both commands to do the same thing the latter one does
 
I see now. Performs two different actions depending on the slash for the first argument, which is what I would expect would happen. Maybe I've just been working on Mac OS X's terminal too long. ;)

I am not sure. Are you sure this works like you would expect on other POSIX-based UNIX systems, and not Linux systems? What versions/flavors of UNIX does this work like you intend on?
 
Back
Top