Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 10-14-2010, 11:38 AM   #1
tank junior
Registered: Apr 2010
Posts: 42

Rep: Reputation: 0
creating tar : shell vs ui, size differs


os :: ubuntu hardy

In a shell script, I am creating a .tar using this command
tar -zcvf dst/lib/library.tar.gz dst/lib
There are two problems:

1. The library.tar.gz is created but inside .tar the folder structure is like this : dist/lib/(all dirs and files). I don't need dist/lib structure inside .tar but all the dirs and files of dist/lib directly under .tar.

2. Using above command .tar is coming out around 7.7 mb in size but when I creating tar by manually selecting all dirs and files and creating .tar by right-click-menu>create archive>(.tat.gz option), .tar is coming out around 4.4 mb. Why is that difference? Is is possible to get more compression but keeping format to .tar.gz using 'tar' shell command?

3. Is it possible to move files when creating a .tar? (create and delete them) or shall I do it manually?


Old 10-14-2010, 12:08 PM   #2
Senior Member
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
1. This is the way that tar works, it will store all path information to the files. This is the only way that will work when adding subdirectories. To remove the unwanted path, you'll have to cd to the /dst/lib directory before executing the tar command.

2. I'm not familiar with .tat files, I'd guess that the compression ratio is different between the two. It does not look like you can specify the compression level on the command line, you'd have to tar and gzip in separate commands or pipe the output to gzip.

cd /dst/lib
tar -cvf - * | gzip -9 > library.tar.gz
3. I'm not sure what the question is here.


compression, tar

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
How come file size differs between ls and df? felixrabe Linux - General 6 01-06-2008 06:26 PM
The same font and it's size differs from Windows to Linux. How to solve it ? aboaventura Linux - General 1 12-20-2006 08:46 AM
File size differs procfs General 3 06-06-2006 09:14 AM
mk2efs ext3 block count differs on same partition size tkmbe Linux - General 1 06-29-2005 09:23 AM
fdisk partition size differs from mounted partition size jimieee Linux - General 3 10-15-2003 03:10 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:16 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration