Remix.run Logo
fullstop 4 days ago

I have so much of tar memorized. cpio is super funky to me, though.

fuzztester 3 days ago | parent [-]

cpio is not that hard.

A common use case is:

  $ cpio -pdumv args 
See:

  $ man cpio 
and here is an example from its Wikipedia page, under the "Operation and archive format" section, under the Copy subsection:

Copy

Cpio supports a third type of operation which copies files. It is initiated with the pass-through option flag (p). This mode combines the copy-out and copy-in steps without actually creating any file archive. In this mode, cpio reads path names on standard input like the copy-out operation, but instead of creating an archive, it recreates the directories and files at a different location in the file system, as specified by the path given as a command line argument.

This example copies the directory tree starting at the current directory to another path new-path in the file system, preserving files modification times (flag m), creating directories as needed (d), replacing any existing files unconditionally (u), while producing a progress listing on standard output (v):

$ find . -depth -print | cpio -p -dumv new-path

fullstop 2 days ago | parent [-]

I think that it's the fact that it requires a pipe to work and that you add files by feeding stdin that throw me for a loop.

I also use it very infrequently compared to tar -- mostly in conjunction with swupdate. I've also run into file size limits, but that's not really a function of the command line interface to the tool.