码迷,mamicode.com
首页 > 系统相关 > 详细

File Compression in Linux

时间:2017-05-13 10:02:31      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:oca   man   pat   sid   create   local   .com   help   bsp   

Compress an Entire Directory or a Single File

Use the following command to compress an entire directory or a single file on Linux. It’ll also compress every other directory inside a directory you specify–in other words, it works recursively.

tar -czvf name-of-archive.tar.gz /path/to/directory-or-file

Here’s what those switches actually mean:

  • -c: Create an archive.
  • -z: Compress the archive with gzip.
  • -v: Display progress in the terminal while creating the archive, also known as “verbose” mode. The v is always optional in these commands, but it’s helpful.
  • -f: Allows you to specify the filename of the archive.

Let’s say you have a directory named “stuff” in the current directory and you want to save it to a file named archive.tar.gz. You’d run the following command:

tar -czvf archive.tar.gz stuff

Or, let’s say there’s a directory at /usr/local/something on the current system and you want to compress it to a file named archive.tar.gz. You’d run the following command:

tar -czvf archive.tar.gz /usr/local/something

技术分享

File Compression in Linux

标签:oca   man   pat   sid   create   local   .com   help   bsp   

原文地址:http://www.cnblogs.com/casperwin/p/6847932.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!