detect if file is bzip compressed on solaris 10

Hi, I recently tried to create a tar archive on a Solaris 10 machine with gnu tar 1.17 and I used the command gtar -cjf filename.tar file1 file2 directory.
The creation was successful but I'm not sure if the file was compressed with bzip as the j option is supposed to do. How can I check that it was compressed?
I have tried the command gtar -tf filename.tar and it lists all files but it doesn't say anything about compression (I left out the j option on purpose to see if gtar would protest)

When I created the archive I thought that the j option would add the .bz2 extension to the file name but it didn't so now I'm confused...:confused:

---------- Post updated at 01:52 PM ---------- Previous update was at 01:45 PM ----------

Hmm, found the solution myself...
I ran bunzip2 filename.tar and it didn't protest about file format (it warned about not being able to guess original file name).
Then I tried bunzip2 somefile.txt and got the message
bunzip2: somefile.txt is not a bzip2 file.

Conclusion: my tar archive was compressed but the file name didn't reflect this and gtar can read a compressed archive even though I don't specify how it is compressed.

perhaps simpler way would be to take a peek at file header.
I think there should be hex viewer in Solaris or something similar to do it.

1 Like

use the "file" utility to check the file header. example:

$ file V26755-01.zip 
V26755-01.zip: Zip archive data, at least v1.0 to extract

this was done on mac os but is similar on solaris.

1 Like