Contact Form

Name

Email *

Message *

Cari Blog Ini

Cpio Extract Single File

CPIO: Linux/UNIX cp in/out Command for Copying, Listing, and Extracting Files

Introduction

The cp command is a powerful tool for copying files or directories in Linux and UNIX systems. It can handle complex directory structures, preserve file attributes, and support various options for handling existing files and directories.

Using the -d Option

The -d option instructs cpio to create leading directories when extracting files. This is useful when extracting files from an archive that contains files and directories that do not yet exist in the current directory.

Example Usage

To extract a single file from a compressed archive (foo.cpio.gz) while creating any necessary directories, you can use the following command:
 gzip -cd foo.cpio.gz | cpio -idmv 

Additional Functions of GNU cpio

GNU cpio, a GNU implementation of cpio, offers additional features beyond basic copying and extraction: * **Copy files to an archive:** `cpio -ocvf archive.cpio file1 file2 ...` * **Extract files from an archive:** `cpio -ivmf archive.cpio` * **List files in an archive:** `cpio -tvmf archive.cpio`


Comments

More from our Blog