Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
First don't put --keep-old-files AND -k. They are two forms (long and short) of the same option. Second invert the groups of option and it should work. This is because the -f option accepts as argument the name of the archive, so that the part f --keep-old-files is interpreted as the name of the archive. In summary the solution is either one of the following
Code:
$ tar --keep-old-files -xvf file.tar
$ tar -xkvf file.tar
Not an interactive dialog, but just an error message. You can either chose --overwrite to force overwriting OR --keep-old-files to prevent this behavior. That is your choice is made prior to run the extraction of the archive, not in run time.
What do you mean for "there are several alternatives for the -k option"? To me the -k option is unique.
What do you mean for "there are several alternatives for the -k option"? To me the -k option is unique.
The "tar --help" file says this:
Code:
-k, --keep-old-files don't replace existing files when extracting
--keep-newer-files don't replace existing files that are newer than
their archive copies
--no-overwrite-dir preserve metadata of existing directories
--overwrite overwrite existing files when extracting
--overwrite-dir overwrite metadata of existing directories when
extracting (default)
--recursive-unlink empty hierarchies prior to extracting directory
--remove-files remove files after adding them to the archive
It makes it look like these are all functions of "-k".
It makes it look like these are all functions of "-k".
Nope. It tells that the -k option is the short form of --keep-old-files, while the other options listed do not have a short form. Indeed they are all related to the behavior of tar in case of already existing files with the same name, but -k is --keep-old-files only.
I see now the reason why you used both -k and --keep-old-files in the same command line. Well, the help can be confusing, but keep in mind that an option may accept one or more arguments, but never accept another option as argument, that is a string beginning with - or --.
Code:
-k, --keep-old-files don't replace existing files when extracting
The comma tells you they are two different alternatives of the same option.
This is the normal behavior. If one or more files already exist, the file(s) are not extracted from the archive and tar gives an error message and an exit status different from zero.
If you've specified "keep" or "-k" then tar shouldn't complain that a file already exists, it should ignore it. I think that's the crux of the problem.
I've been reading through the info pages, and this is what is says verbatum:
Quote:
To be even more cautious and prevent existing files from being replaced, use the `--keep-old-files' (`-k') option. It causes `tar' to refuse to replace or update a file that already exists, i.e., a file with the same name as an archive member prevents extraction of that archive member. Instead, it reports an error.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.