LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   difference in size of the tarred files after archiving using tar command (https://www.linuxquestions.org/questions/linux-newbie-8/difference-in-size-of-the-tarred-files-after-archiving-using-tar-command-881153/)

emagnun 05-17-2011 04:26 AM

difference in size of the tarred files after archiving using tar command
 
i am using red hat linux 2.4 . I have 3 folders dir1 dir2 dir3

I have tarred them like this.
1.tar cvfz tarball_1.tgz dir1 dir2 dir3
2.tar cvfz tarball_2.tgz dir1 dir2 dir3 2>& /dev/null (So that it does not display any error message or operation details to the user)

[usr@machine]$ ls -lrt
-rw-r--r-- 1 usr grp 199843988 May 17 13:39 tarball_1.tgz
-rw-r--r-- 1 usr grp 199837488 May 17 13:53 tarball_2.tgz

But can any one explain the size difference as seen in list output...

sohny 05-17-2011 05:23 AM

did u mean

Quote:

tar cvfz tarball_2.tgz dir1 dir2 dir3 2>& /dev/null
or

Quote:

tar cvfz tarball_2.tgz dir1 dir2 dir3 2>/dev/null
coz I m getting any error as follows with first one

Quote:

-bash: /dev/null: ambiguous redirect
And i m not see any difference with bot commands u mentioned. I m getting same size

colucix 05-17-2011 05:29 AM

The same for me. Apparently there is no reason why they should differ, unless their actual content is different. What is the output of the following?
Code:

diff <(tar tvf tarball_1.tgz) <(tar tvf tarball_2.tgz)

emagnun 05-17-2011 05:33 AM

Quote:

Originally Posted by sohny (Post 4358660)
did u mean



or



coz I m getting any error as follows with first one



And i m not see any difference with bot commands u mentioned. I m getting same size


Hi,

The second command is "tar cvfz tarball_2.tgz dir1 dir2 dir3 2>& /dev/null" only.
I have used this to redirect stdout and stderr so that the ouput as well as the error message(if any) will not be displayed to the user. Its a part of error handling in my script.

I dont understand why you are getting the error while issuing the same...

Pls do reply.

sohny 05-17-2011 06:48 AM

I am actually getting a diff in both files buy doing cmp of both the files created buy just a simple tar withoput redirting. I am assuming the diff is in the info of timestamps of the stored files

@emagnun

I don't know why I m getting that error, but i was able to solve it by putting the "&" before the ">" symbol


All times are GMT -5. The time now is 11:53 PM.