I'm afraid cpio
can't really do this, unless you do some extra scripting to detect the directory pathname and walk through it to extract the pathnames of all files below it, as a way of "pre-processing" your list file.
It would be far easier to use another tool, such as rsync
(note the extra -r
after --files-from
!):
rsync -a --files-from=my-files-to-copy.txt -r my/source/dir my/dest/dir
... or pax
(a standard utility):
( cd my/source/dir && pax -w ) <my-files-to-copy.txt |
( cd my/dest/dir && pax -r )
... or with pax
if you can give an absolute path to the destination directory:
( cd my/source/dir && pax -rw /my/dest/dir ) <my-files-to-copy.txt
... or BSD tar
(use -T
or --files-from=
instead of -I
with GNU tar
):
tar -c -f - -C my/source/dir -I my-files-to-copy.txt |
tar -x -f - -C my/dest/dir
This is all assuming that my-files-to-copy.txt
lives in the current directory and that this directory might be different from the my/source/dir
directory.
cpio
doesn't seem to support recursive copying like you want it to. Would you be able to use any ofpax
,tar
,cp
,rsync
instead?cpio
supports such a copy but with limited meta data support, see man page:schillix.sourceforge.net/man/man1/cpio.1.html - check thepass mode
section.cpio
however neither has a--create
nor a--extract
option. So how did you come to your question?cpio
which does have those options.--create
is an alias for-o
and--extract
is an alias for-i
.cpio
is not a standard utility anymore.