I am writing a scriptwhere in a file there are .zip files and .tar.gz files. I have to extract the files. I know how to use tar for tar.gz and unzip for zip files but don't know how to take decision based on extensions. I have written a script which works for tar.gz. Here is the script.
#!/bin/bash echo "Evaluate Lab" select yn in "Yes" "No"; do case $yn in Yes ) echo "Evaluating!!" #choose file file="$(ls | head -1)" echo $file mkdir temp echo "Decompressing file $file" #Decompress chosen tar.gz to temp tar -xf "$file" --directory temp cd temp/ #Do some work here #get out of temp folder cd ../ rm -rf temp echo "Moving $file to done" mv "$file" ../done/ echo "Evaluate another" echo "1) Yes 2) No" ;; No ) echo "Exiting...." exit;; *) echo "Enter right option";; esac done
I've to work on both tar.gz and zip. Any hints?