You seem to misunderstand the difference between tar and bzip2.
tar is a file archive utility that takes a number of files, with pathnames, and puts them into a single binary file. It doesn't do anything to compress the data.
bzip2 (like gzip and compress) is a file (or stream) compression utility, that takes a single file and makes it smaller.
If you want to create an archive of a directory, you first need to create a tar archive, then bzip2 compress the archive; this is why “tarball”s often have the extension .tar.bz2
Code:
tar -cf file.tar dir && bzip2 file.tar
You can also do this in one step:
Code:
tar -cjf file.tar.bz2 dir
This compresses better than all-in-one formats like ZIP, which compress each file seperately then append then put the compressed files into an archive.
If you want to compress each file within a directory, you can use
To do this recursively you'll need to use find:
Code:
find dir -exec bzip2 '{}' ';'