2

I download swift installation package, and extract it into my home directory:

# tar -C / -xvf swift-2.2.1-RELEASE-ubuntu14.04.tar.gz swift-2.2.1-RELEASE-ubuntu14.04/usr/ swift-2.2.1-RELEASE-ubuntu14.04/usr/include/ swift-2.2.1-RELEASE-ubuntu14.04/usr/include/lldb/ ...... 

The final swift-2.2.1-RELEASE-ubuntu14.04 layout likes this:

# tree -d -L 2 . └── usr ├── bin ├── include ├── lib └── share 5 directories 

I want to extract the files into /usr directory directly and not override other files, is there any method?

2 Answers 2

1

Unless it is a vendor provided package that integrates with the OS package manager you shouldn't extract it in that location. Please go to /opt and extract it there for example and set up your environments variables as shown on the download page for Swift. By doing a full extraction in /opt, which is there for third-party applications, you can also quickly switch between versions by just changing your environment variables.

0

When extracting files, if tar discovers that the extracted file already exists, it normally replaces the file by removing it before extracting it, to prevent confusion in the presence of hard or symbolic links. (If the existing file is a symbolic link, it is removed, not followed.) However, if a directory cannot be removed because it is nonempty, tar normally overwrites its metadata (ownership, permission, etc.). The --overwrite-dir option enables this default behavior. To be more cautious and preserve the metadata of such a directory, use the --no-overwrite-dir option.

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. For example:

$ ls blues $ tar -x -k -f archive.tar tar: blues: Cannot open: File exists tar: Exiting with failure status due to previous errors 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.