Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 11-12-2014, 02:09 AM   #1
Registered: Jan 2012
Posts: 130

Rep: Reputation: Disabled
Question compress directory with tar.bz2 and pv ?

I cant seem t figure out how to compress a directory (test) with tar.bz2 in conjunction with pv.

pv test | tar -zcvf > test2.img.bz2
pv: (stdin): read failed: Is a directory
   0B 0:00:00 [   0B/s] [<=>                                                   ]
tar: option requires an argument -- 'f'
Try 'tar --help' or 'tar --usage' for more information.
I'm Sure theres something wrong with the syntax or something but I cant for the life of me seem to figure it out. Im not even sure what parameters to use, they range from zcvf to cjf to cf to zcvf.

What do I need to use to compress a directory with tar and bz2 and view the progress in pv ?
Old 11-12-2014, 04:59 PM   #2
Registered: Jun 2013
Location: Dubuque, IA
Distribution: Red Hat Enterprise Linux, Mac OS X, Ubuntu, Fedora, FreeBSD
Posts: 89

Rep: Reputation: Disabled
-j is for bz2, "tar -cf -" tells tar to send output to stdout instead of a file. There is not a straightforward way to do this since pv needs to know the size of the items it is working on. The first example answers your question, the second example is just for show.

Example 1:
tar -cf - test | pv -s $(du -sb test | awk '{print $1}') | bzip2 > test.tar.bz2
Example 2:
(tar -cf - test | pv -ns $(du -sb test | awk '{print $1}') | bzip2 > test.tar.bz2) 2>&1 | dialog --gauge 'Progress' 7 70

Last edited by nbritton; 11-12-2014 at 05:54 PM.
1 members found this post helpful.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
best practice of huge directory into tar gz or bz2 salimshahzad Linux - Newbie 2 12-26-2010 08:18 PM
using tar to compress specific files in a directory named a certain way slinky66 Linux - Newbie 3 11-25-2009 02:31 PM
tar doesn't compress .hidden files in the same directory it is run in? BassKozz Linux - Newbie 2 06-02-2009 05:46 PM
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 03:53 AM
compress a directory using tar muskiediver Linux - General 4 07-18-2006 11:24 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:33 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration