I'm trying to make a script where I can unzip a file and then cd into that unzipped file (ie. unzip test.zip and then cd into the test folder). The problem is that the name of the zip file varies and I'm trying to write a script that will work regardless of the name.
Currently, I have:
for file in $(ls *.zip);
do
unzip ${file}
cd ${file};
done
but I'm getting an error because ${file} is still a .zip file (if I understand the error correctly).
Any suggestions?
Thanks.
Edit:To clarify, I'm trying to do analysis on the files that are inside the .zip file. So I think my goal is to unzip the file first (which will then create a directory with the same name as the zip file without the .zip) and then cd into that directory. Once inside that directory, then I would have another line of code that would start the analysis of the files.
for file in $(ls)
. In this case, it isn't even helping at all: it is shorter, easier and safer to dofor file in *zip; do...
.