Linux Tar Description&A Demo Task

Linux Tar Description

DESCRIPTION:

Tar stores and extracts files from a tape or disk archive.

How to use:

The first argument to tar should be a function (list the Most commonly used)
  • -c     create a new archive
  • -x     extract files from an archive
  • -f     use archive file or device ARCHIVE
  • -v     verbosely list files processed
  • -z     gzip
  • -j     bzip2
  • -J     xz

Examples:

  • Create archive.tar from files foo and bar,the archive.tar is the same size of the files
    tar -cf archive.tar foo bar
  • Create archive.tar by using gzip from files foo and bar,z means zip,the sizes decreases
    tar -czf archive.tar foo bar
  • performs the function above but verbosely list files
    tar -czvf archive.tar foo bar
  • this is identical to above except that the files are extracted instead of archived
    tar -zxvf archive.tar

My One Task:

Send the document in 2017 to another server and keep the dir structure fixed.Hovever,there are thousands of small files ,so I should archived all the files located in 2017 directories before transfering for the purpose to Maximum utilization ofnetwork throughput.

Directories:

FutureDB/
├── DCE
│ ├── Day
│ │ ├── 2017.01.29
│ │ ├── …
│ │ ├── 2016.01.29
│ │ ├── …
│ ├── DB
│ └── Night
│ ├── 2017.01.29
│ ├── …
│ ├── 2016.01.29
│ ├── …
├── SHFE
│ ├── Day
│ │ ├── 2017.01.29
│ │ ├── …
│ │ ├── 2016.01.29
│ ├── DB
│ └── Night
│ ├── 2017.01.29
│ ├── …
│ ├── 2016.01.29
└── ZCZE
├── Day
│ ├── 2017.01.29
│ ├── …
│ ├── 2016.01.29
├── DB
└── Night
├── 2017.01.29
├── …

It is very convenient by using this command to archive
   tar czvf /mnt/FutureDBDay.tar $(find /mnt/FutureDB/ -maxdepth 3 -name '2017.*' ) &
How to extract more than one tars
    ls *.tar.gz | xargs -n1 tar xzvf
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值