stiles
04-30-2001, 03:04 PM
I was playing with the -r flag and I'm confused about why it's acting strange. First here's the -r part of cp's manpage:
-r
Recursive. cp will copy the directory and all its files, including any subdirectories and their files to target
That's all good, but when the target does not exist and I'm copying a dir with subdir's I'm getting strange behavior. From reading the manpage I thought that copy would first mkdir <target> and then within target copy the source dir.
ex. cp dir1 dir2 #where dir2 does not exist but dir1 is a dir with a subdirectory
cp creates dir2 but within dir2 is only the subdirectory :confused: I expected that dir2 would be created and would contain dir1 and dir1's subdirectory, instead cp is acting like mv and is renaming dir1 to dir2 but it keeps the original dir1.
again from cp's manpage:
If target_file does not exist, cp creates a new file named target_file that has the same mode as source_file except that the sticky bit is not set unless the user is superuser; the owner and group of target_file are thoes of the user.
I read that to say that cp should mkdir source_file then perform the recersive copy into that dir, but the cp command acts different if the target does not exist.
[ 30 April 2001: Message edited by: stiles ]
-r
Recursive. cp will copy the directory and all its files, including any subdirectories and their files to target
That's all good, but when the target does not exist and I'm copying a dir with subdir's I'm getting strange behavior. From reading the manpage I thought that copy would first mkdir <target> and then within target copy the source dir.
ex. cp dir1 dir2 #where dir2 does not exist but dir1 is a dir with a subdirectory
cp creates dir2 but within dir2 is only the subdirectory :confused: I expected that dir2 would be created and would contain dir1 and dir1's subdirectory, instead cp is acting like mv and is renaming dir1 to dir2 but it keeps the original dir1.
again from cp's manpage:
If target_file does not exist, cp creates a new file named target_file that has the same mode as source_file except that the sticky bit is not set unless the user is superuser; the owner and group of target_file are thoes of the user.
I read that to say that cp should mkdir source_file then perform the recersive copy into that dir, but the cp command acts different if the target does not exist.
[ 30 April 2001: Message edited by: stiles ]