Problems with mass-unzip
Hi there again,
I do have MANY folders called 1,2,3,....,i In all of them is a file called "Output.zip" (same name, different content) I want to do a simple unzip */output.zip (from an upper hierarchy level) What happens is: caution: filename not matched: 9/output.zip and many more cautions. I have no idea, why that is. Any idea? ------- The next step would include the printout of a single line in one of the files located in the zip folder: What i do is the following: cd 1 unzip * grep -c "^>" file1.clstr <write down the result> [a number] cd .. cd 2 unzip * grep -c "^>" file1.clstr* cd .. and repeat. * All output.zips contain the same file structure and names. Now the question is.....can i automate this with a For - loop? with an textfile as an output: Go to dir i, unzip all, give last line of file1, print that as "dir i: result" into a text file. I guess this would demand quite the script, but i am a beginner, and it makes me sad that i am probably spending a lot of time on unnecessary things. So, many thanks again! |
Code:
NAME Here's a loop to get you started: Code:
for i in $(ls); do |
Code:
for i in "*/*.zip";do for some reasons why $(ls) is a bad idea. http://www.tldp.org/LDP/abs/html/refcards.html#AEN22664 for the "${i%/*}" and "${i/*\/}" |
Hi there,
thanks for your help. For feedback: I first tried Firerat`s script, this was the output sh massunzip.sh massunzip.sh: 3: massunzip.sh: pushd: not found massunzip.sh: 4: massunzip.sh: Bad substitution Alucard`s script however works fine. Thank you! |
no pushd?
what shell are you using? ahh, I see you are using sh use bash although Alucard`s script works, it is poor and will fail at some point for instance, when you have a space in the dirname Code:
#!/bin/bash ./massunzip.sh |
Hi, thanks again for putting so much effort in my case. I first have to understand the difference between bash and sh ;), then ill try out your sophisticated version.
Based on Firerat's script, i did the following: Code:
#!/bin/bash |
hmm, not based on my script
has the $(ls) which is just pointless , and 'dangerous' in a script as it will wordsplit whitespace Anyway,,, let us ignore that ... Code:
#!/bin/bash had trouble figuring out exactly what you want and your filesnames changed ( output / file1 ) Oh, above is untested. and personally I would be tempted to only extract the interesting file to a temp dir , work with it and then remove. but I don’t really know what you want out of the whole process |
All times are GMT -5. The time now is 09:00 AM. |