You are not logged in.
Pages: 1
Is this the only way to copy a dir including hidden files it can contain?
for i in $(find -name "/source/dir/.*"); do cp $i /dest/dir/ -a; done
"cp -a" does not copy hidden files.
Offline
cp -r old-directory new-directory
Recursive, copy directory and all subdirs.
doesn't work?
Offline
"cp -a" is an extension of "cp -r"
"cp -a" = "cp -dpR"
-d = don't follow symlinks
-p = preserver ownership
-R = -r = recursively
and no, it does not copy hidden files.
Offline
[..]and no, it does not copy hidden files.
Huh? "cp -a" copies hidden directories (those with ".") just fine for me. I use it all the time. Are you using an alias or something instead?
Hell, I just backed up a user directory with "cp -a /home/user /tmp". All "." subdirectories are there. No problem.
Offline
i've created a directory with a hidden dir and a hiddne file. it has been succesfully copied... I don't know what happens. I'll check it again next time i copy a dir.
Offline
i've created a directory with a hidden dir and a hiddne file. it has been succesfully copied... I don't know what happens. I'll check it again next time i copy a dir.
Anything's always possible. It might very well be that using wildcards while using "cp -a" might have some effect on hidden directories. There's always a way to misuse a system command. I do it all the time, sometimes on purpose. Also, more than likely, you probably didn't have the proper permissions on some of those subdirectories. That's always a possibility, especially if the "other" field is "---", and you're neither owner or part of the group.
Offline
I did it as root: I was moving my opt dir into another hd. So I don't think permissions are the cause of it
Offline
How did you copy the source?
cp -R sourcedir destdir
or
cp -R sourcedir/* destdir
The first one is correct and should copy also hidden files and dirs, the second wrong, because bash parses the wildcard before passing args to cp and hidden files are excluded this way.
Offline
I did the second.
wow, I'd never imagined that this would apply to all hidden files at any directory level after the first.
So next time I'll run
cp -R . /desdir/
thanks
Offline
Pages: 1