lundi 7 mai 2018

Bash, Shell - how to check if file is tar file

My question is about Bash, Shell. I am writing a script and I have the following problem: I have a case when user declares that he or she will extract a file into a dir. But I have to test if the existence and if exist a need to check if that file is a *.tar file. I searched for similar like when checking if the file is executable:

Blockquote

if [ -x "file" ]; then
 echo "file is executable"
else
 echo "file is not executable"

Aucun commentaire:

Enregistrer un commentaire