Working with cpio Archives

It is much less likely that you will need to work very often with cpio archives, so we show here just a simple example of creating an archive and extracting the files from it.

When creating an archive, cpio takes a list of filenames and uses them to decide which files to include in the archive:

[email protected]:~/temp> ls | cpio -vo > ../temp.cpio

This lists the files in the current directory and passes the filenames to cpio, which creates an archive on standard output (the -o option), verbosely (the -v option).

If you want to create an archive containing everything under the current directory, you can use find to list all the relevant paths and pipe its output to cpio:

[email protected]:~/temp> find . | cpio -vo > ../temp.cpio

To unpack an archive, use the following:

[email protected]:~/another_directory > cpio -ivd < ../temp.cpio

This unpacks (the i option) the archive under the current directory, creating new directories as necessary (the -d option).

Was this article helpful?

0 0

Post a comment