LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-21-2014, 02:52 PM   #16
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761

Quote:
Originally Posted by dive View Post
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.
Old 01-21-2014, 04:57 PM   #17
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
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.
 
Old 01-21-2014, 05:42 PM   #18
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,219

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
Quote:
Originally Posted by drmozes View Post
xz -d <file.xz>
Or

Code:
unxz <file.xz>
 
Old 01-22-2014, 10:26 AM   #19
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761
Quote:
Originally Posted by TobiSGD View Post
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 02:15 AM.
 
3 members found this post helpful.
Old 01-22-2014, 10:31 AM   #20
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761
@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 02:13 AM. Reason: Changed the link to a more appropriate page of the manual
 
Old 01-22-2014, 10:45 AM   #21
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
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.
 
Old 01-22-2014, 01:09 PM   #22
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,219

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
Quote:
Originally Posted by stf92 View Post
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.
 
Old 01-22-2014, 09:47 PM   #23
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
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.
 
Old 01-23-2014, 12:48 AM   #24
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761
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 12:54 AM.
 
1 members found this post helpful.
Old 01-23-2014, 07:10 AM   #25
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761
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 07:19 AM.
 
  


Reply


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
Need a utility decompress and recompress Phoenix BIOS on HP notebook. r00tb33r Linux - Hardware 25 08-05-2008 02:36 PM
How do I decompress lzm files? hal8000b Linux - Software 2 09-21-2007 02:15 PM
decompress tar.bz2 files dhamle Linux - Software 2 09-11-2007 10:24 AM
decompress tar gz files? buccaneer Linux - Newbie 5 01-19-2004 02:15 AM
How do you decompress files, or run files such as the Netscape 6 Uninstaller in RH7.2 oudent Linux - Newbie 1 11-19-2001 12:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration