0

I'm trying to accomplish what it says in the title ... but for the life of me I can't figure out the magic invocation.

The LLVM archive I am downloading contains the path clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/clang-format which I want to extract to a specified location.

I'm trying this:

mkdir outdir && curl -L 'https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz' | tar -xz clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/clang-format --directory outdir/ --strip-components=2

But this places nothing in outdir and meanwhile creates the path to extract in the current working directory (which is what I'm trying to avoid with --strip-components).

When I move --strip-components to the front, it strips the path, but places the result in the current directory, ignoring --directory.

What is the correct way to do this?


End goal: Extract clang-format binary to /usr/local/bin/.

1 Answer 1

0

It seems that --strip-components and -C options need to precede the file to extract, otherwise they are silently ignored.

I suppose the man page hints at this

tar -x [-f ARCHIVE] [OPTIONS] [MEMBER...]

But in some contexts (https://askubuntu.com/a/45354/596667) it seems to be ok at the end.

The correct command line is thus

mkdir outdir && curl -L 'https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz' | tar  --directory outdir/ --strip-components=2 -xz clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/clang-format

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .