Slackware This Forum is for the discussion of Slackware Linux.
|
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
|
01-21-2014, 03:52 PM
|
#16
|
Senior Member
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557
|
Quote:
Originally Posted by dive
If you want to compress a file/folder:
tar cfpJ the archivename.tar.xz filename
to decompress do as dugan said above
|
'a' instead of 'J' so the ending decides the compression format. That way you don't need to remember as many switches/options.
|
|
2 members found this post helpful.
|
01-21-2014, 05:57 PM
|
#17
|
Moderator
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
|
Also, keep in mind that when you use the f option that it has to be that last option. The above command will create an archive name pJ.
|
|
|
01-21-2014, 06:42 PM
|
#18
|
LQ Guru
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,351
|
Quote:
Originally Posted by drmozes
xz -d <file.xz>
|
Or
|
|
|
01-22-2014, 11:26 AM
|
#19
|
Senior Member
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557
|
Quote:
Originally Posted by TobiSGD
Also, keep in mind that when you use the f option that it has to be that last option. The above command will create an archive name pJ.
|
Not true. If you don't use a - in front you can have any order you like for the short options, with the only problem being that options must be the first argument as a group, with the archive name second and the files/folders next. [EDIT]: I have since realised this is not entirely true either, proceed to my later post afterwards for a further clarification of how old style options work
The following are all valid and do exactly the same thing:
Code:
tar cf archive.tar files
tar fc archive.tar files
tar -cf archive.tar files
tar -c -f archive.tar files
tar -f archive.tar -c files
tar --create --file=archive.tar files
tar --file=archive.tar files --create
You can also mix and match as long as you remember to keep the short options without a - as the first argument, e.g.:
Code:
tar f archive.tar -c files
tar c --file=archive.tar files
These are not valid:
Code:
tar -fc archive.tar files
tar c f archive.tar files
tar f archive.tar c files
Last edited by ruario; 01-23-2014 at 03:15 AM.
|
|
3 members found this post helpful.
|
01-22-2014, 11:31 AM
|
#20
|
Senior Member
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557
|
@TobiSGD: You might find the "3.3.3 Old Option Style" and "3.3.4 Mixing Option Styles" sections of the GNU tar manual interesting:
http://www.gnu.org/software/tar/manu...on/Styles.html
Last edited by ruario; 01-23-2014 at 03:13 AM.
Reason: Changed the link to a more appropriate page of the manual
|
|
|
01-22-2014, 11:45 AM
|
#21
|
Senior Member
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442
Original Poster
Rep:
|
Do you know what the Byzantines did when the Turks were at the gates? They were engaged in questions such as: were the Father and the Son of the same substance? Such questions came to be known as Byzantine discussions.
|
|
|
01-22-2014, 02:09 PM
|
#22
|
LQ Guru
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,351
|
Quote:
Originally Posted by stf92
Do you know what the Byzantines did when the Turks were at the gates? They were engaged in questions such as: were the Father and the Son of the same substance? Such questions came to be known as Byzantine discussions.
|
Stop trying to shut down the discussion.
|
|
|
01-22-2014, 10:47 PM
|
#23
|
Moderator
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
|
Thanks for the correction, didn't know that there is a difference when using the - in front of the options, I always use that format. My brain just can't handle the newer format.
|
|
|
01-23-2014, 01:48 AM
|
#24
|
Senior Member
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557
|
Actually without using a - is the "Old Option Style" (how tar has traditionally worked), while with a - is a more modern invention that the tar manual calls the "Short Option Style". In addition there is -- and a keyword (e.g. --file) which they call the "Long Option Style".
Although I prefer "Old Option Style" since it is generally shorter, re-reading the online manual now I realise that I hadn't fully appreciated how it worked and actually explained it incorrectly above. Suppose I wanted to extract archive.tar to the root directory, previously I would have written:
Code:
tar xf archive.tar -C /
I used "Old Option Style" at the beginning and a "Short Option Style" switch at the end. This was because I believed that the second argument had to be the archive. However now I see that this is not true. All of following also work using only "Old Option Style":
Code:
tar Cfx / archive.tar
tar Cxf / archive.tar
tar fCx archive.tar /
tar fxC archive.tar /
tar xCf / archive.tar
tar xfC archive.tar /
The options that take a value must be in the same order as the arguments that come after then, so if 'f' is before 'C' then it is 'archive /' but if 'C' is first then it is '/ archive'. It is logical, though it may take me a little getting used to.
Last edited by ruario; 01-23-2014 at 01:54 AM.
|
|
1 members found this post helpful.
|
01-23-2014, 08:10 AM
|
#25
|
Senior Member
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557
|
Even though I believe I could disarm the bomb, https://xkcd.com/1168/ is still relevant and highlights the complexity of a 'simple' utility like tar.
P.S. A slightly better version would have been if the way to disarm the bomb was to look at a tar command and decide which of three actions it performs. My reasoning is that I actually think most (linux/UNIX) people could provide a valid tar command but they could not understand every valid tar command in much the same way as many people can write a regex but understanding all regex is a different matter!
Before the start of this thread how many here would have known what "tar Cfx / archive.tar" did, without looking online or at the manual. I know that I at least would have failed.
Last edited by ruario; 01-23-2014 at 08:19 AM.
|
|
|
All times are GMT -5. The time now is 01:48 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|