Linux common commands-20: tar

The role of the tar command is to create archives for files and directories, which is what we often call packaging. It should be noted here that packaging is packaging, and compression is compression.

Syntax format: tar [parameter] [file or directory]

Common parameters:

Example

 # 将当前文件夹下的jpg文件打包tar -cf images.tar *.jpg # 打包后删除jpg文件tar -cf images.tar *.jpg --remove-files # 列出包内的文件tar tf images.tar # 提取包内的文件tar xf images.tar # 将test.jpg从包中删除tar --delete -f images.tar test.jpg # 打包后,使用gzip进行压缩tar -zcvf images.tar.gz *.jpg # 打包后,使用bzip2进行压缩tar -cjf images.tar.bz2 *.jpg

This article is reprinted from https://xugaoxiang.com/2022/06/04/linux-cmds-20-tar/
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment