I have a cpio archive with lots of files and I need to extract only one file, not all. With tar
I could just use tar -xf archive.tar path/to/file
, but that does not work with cpio
:
cpio -i < archive.cpio path/to/file
bash: path/to/file: No such file or directory
Does anyone know how to extract just a single file from a cpio
archive?
Best Answer
You should use the
-d
option to letcpio
create the leading directories (path/to
) if they don't exist:Also,
bsdtar
(the regulartar
on FreeBSD) knows how to extract cpio archives, whether compressed or not.