{"id":169,"date":"2026-04-19T10:27:03","date_gmt":"2026-04-19T09:27:03","guid":{"rendered":"https:\/\/vpp.dk\/?linux_trick=extract-any-archive-in-one-command"},"modified":"2026-04-19T10:27:03","modified_gmt":"2026-04-19T09:27:03","slug":"extract-any-archive-in-one-command","status":"publish","type":"linux_trick","link":"https:\/\/vpp.dk\/?linux_trick=extract-any-archive-in-one-command","title":{"rendered":"Extract any archive in one command"},"content":{"rendered":"<p>A universal extract function you can add to ~\/.bashrc \u2014 handles tar.gz, zip, bz2, 7z and more.<\/p>\n","protected":false},"template":"","meta":{"_trick_code":"extract() {\n  case \"$1\" in\n    *.tar.bz2) tar xjf \"$1\" ;;\n    *.tar.gz)  tar xzf \"$1\" ;;\n    *.tar.xz)  tar xJf \"$1\" ;;\n    *.zip)     unzip \"$1\"   ;;\n    *.7z)      7z x \"$1\"    ;;\n    *.gz)      gunzip \"$1\"  ;;\n    *)         echo \"Unknown format: $1\" ;;\n  esac\n}\n\n# Usage:\nextract archive.tar.gz","_trick_uploader":"bashscripter"},"trick_category":[16,22],"class_list":["post-169","linux_trick","type-linux_trick","status-publish","hentry","trick_category-file-management","trick_category-scripting"],"_links":{"self":[{"href":"https:\/\/vpp.dk\/index.php?rest_route=\/wp\/v2\/linux_trick\/169","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vpp.dk\/index.php?rest_route=\/wp\/v2\/linux_trick"}],"about":[{"href":"https:\/\/vpp.dk\/index.php?rest_route=\/wp\/v2\/types\/linux_trick"}],"wp:attachment":[{"href":"https:\/\/vpp.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=169"}],"wp:term":[{"taxonomy":"trick_category","embeddable":true,"href":"https:\/\/vpp.dk\/index.php?rest_route=%2Fwp%2Fv2%2Ftrick_category&post=169"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}