Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I play OpenTTD. There are three versions available and I want to have all three; stable, testing and nightly. I downloaded and compiled the source code for all three with no problems. The issue is when I want to compile a new version. When I extract the tar.xz file into /usr/lib/games/openttd-trunk/ the old files aren't overwritten. Instead, a new directory is created called openttd-trunk-r26175.

Is there any way to extract the files from the archive directly into /usr/lib/games/openttd-trunk/? That way I can just simply make without having to ./configure every time.

EDIT: I don't think I made clear that the archive has the source files inside a single folder called openttd-trunk-r26175. What I want to do is extract all files from that folder, but not the folder itself.

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

See this answer.

If you archive has one top level folder you can use --strip-components 1, to remove first folder from full files path.

Finaly, this should do what you want:

tar xf openttd-trunk-r26175.tar -C /usr/lib/games/openttd-trunk/ --strip-components 1
share|improve this answer
add comment

You can use the --strip-components tar argument to remove leading directory components, and use the -C option to specify a target location for the resulting files e.g.

tar xvf openttd-trunk.tar.xz --strip-components=1 -C /usr/lib/games/openttd-trunk/
share|improve this answer
add comment

I don't think I made clear that the archive has the source files inside a single folder called openttd-trunk-r26175. What I want to do is extract all files from that folder, but not the folder itself

I think you might want to try out the dtrx extractor.

sudo apt-get install dtrx

In that situation what you mentioned dtrx asks for you to decide what to do? From its manpage:

Normally, if an archive only contains one file or directory with a name that doesn't match the archive's, dtrx will ask you how to handle it.

          Extract the file/directory inside another directory named after the archive.  This is the default.

          Extract the file/directory in the current directory, and then rename it to match the name of the archive.

          Extract the file/directory in the current directory.

It also has the -o option to overwrite a present directory if you want that. So the command what you need is likely:

dtrx -o --one rename openttd-trunk.tar.xz

(Of course this can be achieved in other ways too, but dtrx is kinda handy program so you might want to try it out.)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.