Skip to Content
Linux Shell Scripting Cookbook - Third Edition
book

Linux Shell Scripting Cookbook - Third Edition

by Clif Flynt, Sarath Lakshman, Shantanu Tushar
May 2017
Beginner
552 pages
28h 47m
English
Packt Publishing
Content preview from Linux Shell Scripting Cookbook - Third Edition

How to do it...

  1. The pbzip2 command will compress a single file:
        pbzip2 myfile.tar

pbzip2 detects the number of cores on your system and compresses myfile.tar, to myfile.tar.bz2.

  1. To compress and archive multiple files or directories, we use pbzip2 in combination with tar, as follows:
        tar cf sav.tar.bz2 --use-compress-prog=pbzip2 dir

Alternatively, this can be used:

        tar -c directory_to_compress/ | pbzip2 -c > myfile.tar.bz2
  1. Extracting a pbzip2 compressed file is as follows:

The -d flag will decompress a file:

        pbzip2 -d myfile.tar.bz2

A tar archive can be decompressed and extracted using a pipe:

        pbzip2 -dc myfile.tar.bz2 | tar x
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Linux Shell Scripting - Second Edition

Mastering Linux Shell Scripting - Second Edition

Mokhtar Ebrahim, Andrew Mallett

Publisher Resources

ISBN: 9781785881985