Is there a variant of the "cp -a" command that avoids copying from other filesystems?
6,231
On a machine with the GNU Coreutils (most Linux distros), the cp
command has -x
.
From cp man page:
-x, --one-file-system
Related videos on Youtube
Author by
Cerber
Updated on September 18, 2022Comments
-
Cerber almost 2 years
Let's say I have a directory
/data/something
with the following subdirs:/data/something/iowa /data/something/wyoming /data/something/burkinafaso /data/something/slovenia
All four subdirs have content.
burkinafaso
andslovenia
are mount points;iowa
andwyoming
are not. I want to copy the directory structure in such a way thatiowa
andwyoming
get copied recursively with all their subtrees, butburkinafaso
andslovenia
are copied as empty.cp
doesn't seem to have such a switch, unlikedu -x
andfind -xdev
. What's the best way to do what I want?-
Gilles 'SO- stop being evil' almost 9 yearsWhat strange system do you have where
du
has a-x
option butcp
doesn't? -
Cerber almost 9 yearsI am sorry. I DO know how to use a manpage, but somehow managed to miss the -x switch in there.
-