From f3bf0d97a7b5208d1c58bfb5080de50a5068d205 Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Tue, 25 Aug 2020 20:33:18 +0200 Subject: [PATCH] Decompress script: add parameters --- datasets/decompress.sh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/datasets/decompress.sh b/datasets/decompress.sh index 691df92..f95631e 100755 --- a/datasets/decompress.sh +++ b/datasets/decompress.sh @@ -1,8 +1,24 @@ #!/bin/bash -filenames=$( ls *.tar.xz ) +comm="new" # decompress only new files -for filename in ${filenames[@]}; do - echo "Decompressing ${filename}" - tar -xJf "${filename}" +if [[ $# -eq 1 ]]; then + comm="$1" +fi + +echo $comm + +source_filenames=$( ls *.tar.xz ) + +for source_filename in ${source_filenames[@]}; do + target_filename=$(basename $source_filename) + target_filename="${target_filename%.*}" # remove .xz extension + target_filename=$(basename $target_filename) + target_filename="${target_filename%.*}" # remove .tar extension + if [ "$comm" == "all" ] || [ ! -f $target_filename ]; then + echo "Decompressing ${source_filename}" + tar -xJf "${source_filename}" + else + echo "Skipping ${source_filename}" + fi done