mercredi 1 avril 2020

Problems with script that unzips multiple zipped tar files then untars the same files in C shell

I've been trying to write a script that will search a directory for multiple tar files that are zipped, unzip them, then untar them. However my problem is that everytime I run the script it will execute the first if then statement, but it won't execute the second one. I've ran them both statements in separate scripts and they both work independently, however not when ran in the same script. Do I need to combine them in a if then elseif statement? Here's what I have so far, I appreciate any help.

#!/bin/csh
set x = (`find /Documents/*.gz -print`)
set v = (`find /Documents/*.tar -print`)

If ("$x" != "") 
then 
gunzip *
else
echo "No zip files found."
endif

if ("$v" != "")  then
foreach i ( $v )
tar -xvf $i
end
else
echo "No tar files found."
endif

Aucun commentaire:

Enregistrer un commentaire