bash - How do I set case for tar, gz and tar.gz files? -


i have few files in directory this:

xxx.tar.gz xxx.tar yyy.tar.gz yyy.tar zzz.txt.gz ... ... 

i have list.txt files this:

list.txt:

/home/phe/xxx.tar.gz /home/phe/xxx.tar /home/phe/yyy.tar.gz /home/phe/yyy.tar /home/phe/zzz.txt.gz ... ... 

i need extract these files this:

for file in (cat list.txt);    tar zxvf $file done 

how can open tar.gz, txt.gz , tar files in same command?

you that:

while ifs= read -r file;     file="${file##*/}" # remove directory     case $file in         *.tar.gz)             tar xzvf "$file"             ;;         *.txt.gz)             gzip -d "$file"             ;;     esac done < list.txt 

note tar command suspect need specify output directory -c because otherwise extracted in current directory.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -