From c39d7f1327cec2fa99a1efc7cbc8ad8b128f4184 Mon Sep 17 00:00:00 2001 From: Kamil Date: Thu, 2 Dec 2021 16:19:52 +0000 Subject: [PATCH] Update ultimate_extractor.nu wrote --help --- data_extraction/ultimate_extractor.nu | 40 +++++++++++++-------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/data_extraction/ultimate_extractor.nu b/data_extraction/ultimate_extractor.nu index e7f5312..d7383e2 100644 --- a/data_extraction/ultimate_extractor.nu +++ b/data_extraction/ultimate_extractor.nu @@ -1,25 +1,23 @@ -#As in the file name, the script is designed to conveniently handle any archive format - -#usage: extract archive_name - -def extract [name:string] { +#Function to extract archives with different extensions +def extract [name:string #name of the archive to extract +] { let exten = [ [ex com]; - ['.tar.bz2' 'tar xjf'] - ['.tar.gz' 'tar xzf'] - ['.bz2' 'bunzip2'] - ['.rar' 'unrar x'] - ['.tbz2' 'tar xjf'] - ['.tgz' 'tar xzf'] - ['.zip' 'unzip'] - ['.7z' '/usr/bin/7z x'] - ['.deb' 'ar x'] - ['.tar.xz' 'tar xvf'] - ['.tar.zst' 'tar xvf'] - ['.tar' 'tar xvf'] - ['.gz' 'gunzip'] - ['.Z' 'uncompress'] - ] - + ['.tar.bz2' 'tar xjf'] + ['.tar.gz' 'tar xzf'] + ['.bz2' 'bunzip2'] + ['.rar' 'unrar x'] + ['.tbz2' 'tar xjf'] + ['.tgz' 'tar xzf'] + ['.zip' 'unzip'] + ['.7z' '/usr/bin/7z x'] + ['.deb' 'ar x'] + ['.tar.xz' 'tar xvf'] + ['.tar.zst' 'tar xvf'] + ['.tar' 'tar xvf'] + ['.gz' 'gunzip'] + ['.Z' 'uncompress'] + ] + let command = ($exten|where $name =~ $it.ex|first) if ($command|empty?) { echo 'Error! Unsupported file extension'