Decompress script: add parameters

This commit is contained in:
Eugen Betke 2020-08-25 20:33:18 +02:00
parent 88e994f997
commit f3bf0d97a7
1 changed files with 20 additions and 4 deletions

View File

@ -1,8 +1,24 @@
#!/bin/bash #!/bin/bash
filenames=$( ls *.tar.xz ) comm="new" # decompress only new files
for filename in ${filenames[@]}; do if [[ $# -eq 1 ]]; then
echo "Decompressing ${filename}" comm="$1"
tar -xJf "${filename}" 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 done