美文网首页
Tar Command Daily Work Summary

Tar Command Daily Work Summary

作者: 海胆阶段 | 来源:发表于2019-02-22 13:27 被阅读6次

This article used to walk you through some commonly tar usages , based on a real life scenario.

################################################################
#   Date           Description
#   02/28/2019     dash or not
#   02/27/2019     untar to specified folder
#   02/22/2019     list tar content
#   02/21/2019     tar exclude
#   02/20/2019     untar multiple files
#   02/19/2019     tar multiple files
#
################################################################

02/19/2019

Basic operation: tar multiple files into example.tar.gz

tar czf example.tar.gz file1 file2 file3 …

02/20/2019

When untar multiple files, you cannot do this, it will fail

tar zxf file1 file2 file3

The reason please see this link, the solution is to use xargs instead:

ls *.tar.gz | xargs -i tar xzf {}

Or you can use find with -exec

find . -maxdepth 1 -name "*.tar.gz" -exec tar zxf '{}' \;

02/21/2019

For example, if you want to tar things inside a folder but exclude some files

tar czf target.tar.gz ./* --exclude='createInstallerTar.sh' --exclude="target.tar.gz" --exclude='pushBIPayload.sh'

If you don’t exclude target.tar.gz, it will tar itself again.

02/22/2019

List tar.gz file content, flag z is used to distinguish tar and tar.gz

tar ztvf target.tar.gz

02/27/2019

If you don't specify target folder, untar will put things in current directory, use -C option to specify it. For example, I want to untar source.tar.gz file to /etc/yum.repos.d/ folder:

tar zxf /tmp/source.tar.gz -C /etc/yum.repos.d/

02/28/2019

Sometimes I see people use -czf but sometimes czf, dash or not to pass flags?

Historical and compatible reason, no dash version is probably more portable.

tar is one of those ancient commands from the days when option syntax hadn't been standardized. Because all useful invocations of tar require specifying an operation before providing any file name, most tar implementations interpret their first argument as an option even if it doesn't begin with a -. Most current implementations accept a -.

相关文章

  • Tar Command Daily Work Summary

    This article used to walk you through some commonly tar u...

  • Awk Command Daily Work Summary

    This article used to walk you through some commonly awk u...

  • Ssh and Scp Daily Work Summary

    This article used to walk you through some commonly ssh a...

  • Yum and Rpm Daily Work Summary

    This article used to walk you through some commonly yum a...

  • Work Summary

    在做业务逻辑的API层对参数做严格校验避免在Service层、DAO层出现由于参数错误而引起的错误。——2016-...

  • Daily summary

    1 hour BGT watching 2 hours reading 2 hours teaching plan

  • Work Daily

    每个项目开始之前都要写一个大概的任务列表。确定每个模块,每个功能花费的时间。 每天下班之前到redmine登记工时...

  • Daily work

    ![](file:///C:\Users\v_czjzhang\AppData\Roaming\Tencent\U...

  • daily work

    上午: 回复询盘,消息 挑选照片,拍摄新照片 整理客户资料 发微信状态 下午: 更新动态。 WhatsApp, F...

  • What I received in 2017

    summary of the past year Work In 2017, I achieved one of ...

网友评论

      本文标题:Tar Command Daily Work Summary

      本文链接:https://www.haomeiwen.com/subject/evxeyqtx.html