extract() { case "$1" in *.tar.gz) tar xzf "$1" ;; *.zip) unzip "$1" ;; *.gz) gunzip "$1" ;; *) echo "Unknown" ;; esac; }
Universal extract function — handles tar.gz, zip, gz, etc
Instead of remembering different flags for each archive type, this function detects the extension and runs the right command. Extend the case statement for .bz2, .xz, .7z, .rar as needed.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.