linux压缩和解压缩_Linux QuickTip:一步下载和解压缩

linux压缩和解压缩

linux压缩和解压缩

Most of the time, when I download something it’s a file archive of some kind – usually a tarball or a zip file. This could be some source code for an app that isn’t included in Gentoo’s Portage tree, some documentation for an internal corporate app, or even something as mundane as a new WordPress installation.

大多数时候,当我下载某些东西时,它是某种文件存档-通常是tarball或zip文件。 这可能是Gentoo的Portage树中未包含的某个应用程序的源代码,内部公司应用程序的一些文档,甚至可能是与新的WordPress安装一样平凡的东西。

The traditional way of downloading and untarring something in the terminal would be something like this:

在终端中下载和解压缩某些内容的传统方式如下:

wget http://wordpress.org/latest.tar.gz

wget http://wordpress.org/latest.tar.gz

tar xvzf latest.tar.gz

tar xvzf Latest.tar.gz

rm latest.tar.gz

rm Latest.tar.gz

Or perhaps the more compact form:

或者更紧凑的形式:

wget http://wordpress.org/latest.tar.gz && tar xvzf latest.tar.gz && rm latest.tar.gz

wget http://wordpress.org/latest.tar.gz && tar xvzf Latest.tar.gz && rm Latest.tar.gz

Either way is a bit clumsy. This is a very simple operation, a powerful shell like bash should allow such a task to be performed in a more “slick” manner.

两种方法都比较笨拙。 这是一个非常简单的操作,像bash这样的功能强大的shell应该允许以“更流畅”的方式执行此类任务。

Well, thanks to a useful little command “curl”, we can actually accomplish the mess above in just one piped statement:

好吧,多亏了一个有用的小命令“ curl”,我们实际上可以在一个管道语句中完成上述混乱:

curl http://wordpress.org/latest.tar.gz | tar xvz

卷曲http://wordpress.org/latest.tar.gz | 焦油xvz

No temporary files to get rid of, no messing around with ampersands. In short, a highly compact, efficient command. In fact, from a theoretical standpoint, the curl method can be faster than the concatenated wget/tar/rm mess since stdout piping will use RAM as a buffer if possible, whereas wget and tar (with the -f switch) must read/write directly from a disk.

没有要删除的临时文件,也没有与“&”号混为一谈。 简而言之,是一种高度紧凑,高效的命令。 实际上,从理论上讲,curl方法可能比连接的wget / tar / rm混乱更快,因为如果可能,stdout管道将使用RAM作为缓冲区,而wget和tar(使用-f开关)必须读/写直接从磁盘。

Incidentally, tar with the -v option (the way we’re using it in all the above examples) prints each file name to stdout as each is untarred. This can get in the way of curl’s nice, ncurses output showing download status. We can silence tar by invoking it without -v thusly:

顺便说一句,带有-v选项的tar(在以上所有示例中,我们都使用它的方式)将每个文件名打印到stdout,因为每个文件都未解压缩。 这可能会妨碍curl的显示,ncurses输出显示下载状态。 我们可以通过不带-v的方式调用tar来使其静音:

curl http://wordpress.org/latest.tar.gz | tar xz

卷曲http://wordpress.org/latest.tar.gz | 焦油xz

And that’s all there is to it!

这就是全部!

翻译自: https://www.howtogeek.com/howto/uncategorized/linux-quicktip-downloading-and-un-tarring-in-one-step/

linux压缩和解压缩

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值