Skip to content

Instantly share code, notes, and snippets.

@mikybars
Last active February 8, 2019 14:59
Show Gist options
  • Save mikybars/25a85b5360481576dac26017c085ecad to your computer and use it in GitHub Desktop.
Save mikybars/25a85b5360481576dac26017c085ecad to your computer and use it in GitHub Desktop.
Nice one-liner when you want to extract a file from a tarball hosted somewhere but you don't want to deal with temporary files. File is copied to the target directory with path stripped.
$ URL="https://github.com/sharkdp/bat/releases/download/v0.9.0/bat-v0.9.0-x86_64-unknown-linux-musl.tar.gz"
$ TARPATH="$(basename $URL .tar.gz)/bat"
$ TO=~/bin
$ curl -fsSL $URL | tar xzf - -C $TO --transform="s,$(dirname $TARPATH)/,," $TARPATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment