Skip to content

Instantly share code, notes, and snippets.

@gngdb
Created April 18, 2024 23:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gngdb/f0186e47a6af0e25920dcb538c91f687 to your computer and use it in GitHub Desktop.
Save gngdb/f0186e47a6af0e25920dcb538c91f687 to your computer and use it in GitHub Desktop.
# function to untar arxiv source files into a folder
untar_arxiv () {
# Check if the file has a .tar.gz suffix
if [[ $1 == *.tar.gz ]]; then
# Extract the base name without the .tar.gz suffix
base_name=$(basename "$1" .tar.gz)
mkdir -p "$base_name"
tar -xvf "$1" -C "$base_name"
else
# Add the .tar.gz suffix to the filename
mv "$1" "$1.tar.gz"
# Extract the base name without the .tar.gz suffix
base_name=$(basename "$1")
mkdir -p "$base_name"
tar -xvf "$1.tar.gz" -C "$base_name"
rm "$1.tar.gz"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment