Wednesday, November 6, 2019

tarf - Pull Selected Files From a Tarball

alias tarf='_(){ (($#<1))||[[ "${1}" =~ ^- ]]&&echo "Usage: tarf <wildcardname eg.*ocean*pdf> <tarfile> <output dir-default=.>"&&return 1;local wildname="${1}";local tar="${2}";local location="${3:-.}";tar -xf "${tar}" -C "${location}" --wildcards "${wildname}" --transform "s,.*/,,";};_'
This alias makes it really easy to grab individual files from a tarball to the current [or specified] directory. Without having to dig through the directory structure or even knowing the exact name of the file. E.g. tarf '*mp4' media.tar.gz ~/mymp4s/;

Get the latest on GitHub.

No comments:

Post a Comment