SlackwareThis 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.
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.
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
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.
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.