cpio
圧縮と転送
書き方
find <path> | cpio -o > <archive.cpio>何を詰めるかを標準入力から受けた名前の一覧で決める古い書庫道具で、その一覧はふつう find が作ります。`-o` が書き出し、`-i` が取り出し、`-t` が一覧、initramfs が使う可搬な形は `-H newc`、他人からもらった書庫は絶対パスに展開されないよう `--no-absolute-filenames` を添えます。
よく使うオプション
| オプション | 意味 |
|---|---|
| -o | Copy-out: build an archive from the names arriving on stdin. |
| -i | Copy-in: extract from an archive on stdin. |
| -d | Create directories as needed while extracting. |
| -m | Preserve modification times. |
| -t | List the contents instead of extracting. |
| -v | Print names as they are processed. |
| -H newc | The portable SVR4 format, and the one initramfs images use. |
| --no-absolute-filenames | Refuse to extract to absolute paths from an untrusted archive (GNU cpio only). |
例
find . -depth -print | cpio -ov -H newc > backup.cpioArchive exactly the file list that find produced.
cpio -idmv < backup.cpioExtract, creating directories and keeping timestamps.
cpio -itv < backup.cpioList what is inside first.
まとめることと縮めることは別の仕事です。tar がまとめ、gzip が縮め、.tar.gz はその両方です。
読み方
- 角括弧 [ ] は省いてよい部分です。
- 三点 … は複数並べられるという意味です。
- オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。
よくある質問
Q. cpio は何をしますか。
何を詰めるかを標準入力から受けた名前の一覧で決める古い書庫道具で、その一覧はふつう find が作ります。`-o` が書き出し、`-i` が取り出し、`-t` が一覧、initramfs が使う可搬な形は `-H newc`、他人からもらった書庫は絶対パスに展開されないよう `--no-absolute-filenames` を添えます。
Q. どう打ちますか。
find <path> | cpio -o > <archive.cpio> — 角括弧は省いてよい部分です。
Q. よく使うオプションはいくつですか。
ここにまとめたのは8個です。全部は man cpio にあります。このコマンドは圧縮と転送の仲間です。
関連するコマンド
man ページ: man cpio