Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The usage of the Linux basic command cpio

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "the usage of Linux basic command cpio". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian slowly and deeply to study and learn "the usage of Linux basic command cpio" together!

cpio

Copy files from or to an archive. This command applies to Red Hat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.

The Cpio command has three modes of operation:

1) copy-out mode, the cpio directive copies files to the archive. It reads a list of file names (one per line) on standard input and writes archived packages to standard output.

2) copy-in mode, cpio command copies files from archive, reads archive packages from standard input.

3) cpio-pass mode, which copies files from a directory tree to another directory, reads the list of files to copy from standard input.

1. Grammar

cpio -o namelist > archive

cpio -i

< archive cpio -p dst-dir < namelist 2、选项列表 选项 说明 -? | --help 帮助信息 --version 显示命令版本信息 主操作模式 -i | --extract 从包中提取文件,copy-in模式 -o | --create 创建包,copy-out模式 -p | --pass-through 运行copy-pass模式 -t | --list 打印输入内容列表 -l | --list 对于每一个压缩的文件,列出压缩文件大小、解压大小、压缩比列、压缩前的文件名字 应用在所有模式的选项 -B 设置IO块的大小为5120字节 -c 使用老式跨平台的归档格式 -f 仅拷贝不匹配任意给定模式的文件 -F 用文件名代替标准输入和输出 -n | --numeric-uid-gid 在内容列表的详细信息中显示uid和gid --quite 不打印以拷贝的块数 -v | --verbose 详细信息 -V | -dot 每处理一个文件就打印一个"." 应用于copy-in的徐昂想 -b | --swap -r | --rename 交互式重命名 -E 把指定文件的内容当做匹配字符串 应用于copy-out的选项 -A | --append 追加到文档的结尾 -O 使用包文件名,而不是标准输入输出 应用于copy-pass的选项 -l | --link 在执行时尽可能创建链接,而不是复制文件 应用于copy-in和copy-out --absolute-filenames 文件名不出去文件系统前缀 --no-absolute-filenames 当前目录创建所有文件 应用于copy-out和copy-pass -0 | --null 输入文件名以null字符结尾 -a | --reset-access-time 文件读取后,还原文件的访问时间 -I 从文件读入 -R | --owner 设置所有文件的组合用户信息 应用于copy-in和copy-pass -d 必要时创建目录 -m 创建文件是,保留文件修改时间属性 -u 无条件覆盖 3、例子代码 % ls | cpio -ov >

directory.cpio

Archive the contents of the current directory and create an output file

% find . -print -depth | cpio -ov > tree.cpio

Archive the entire directory tree, and the find command provides a list of files to cpio. This takes all the files in the current directory, as well as the directories below, and places them in the archive directory tree.cpio

% cpio -iv

< directory.cpio 这将检索存档在文件directory.cpio中的文件,并将它们放在当前目录中 % cpio -idv < tree.cpio 这将获取存档tree.cpio的内容,并将其解压缩到当前目录。 % find . -depth -print0 | cpio --null -pvd new-dir 将当前目录的文件和子目录复制到一个名为new-dir的新目录中 4、实例 1)将当前目录归档 [root@localhost weijie]# ls | cpio -o >

mybak //direct the output of ls to cpio, then archive

1 block

[root@localhost weijie]# ls

11.c 1.c 2.c 3.c 4.c 5.c 6.c mybak

2) Extract files from archives

[root# cpio -i < mybak //extract from archive

cpio: not created 11.c: an updated or equally new version exists

cpio: not created 5.c: an updated or equally new version exists

cpio: not created 6.c: an updated or equally new version exists

cpio: mybak not created: an updated or equally new version exists

1 block

[root@localhost weijie]# ls

11.c 1.c 2.c 3.c 4.c 5.c 6.c mybak

3) Copy files

[root@localhost weijie]# cat list.c

1.c

2.c

3.c

[root@localhost weijie]# cpio -p bak/

cpio: ignore blank lines

1 block

[root@localhost weijie]# ls bak/

1.c 2.c 3.c

Thank you for reading, the above is the "Linux basic command cpio usage" of the content, after the study of this article, I believe we have a deeper understanding of the Linux basic command cpio usage of this issue, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report