unzip with subdirectorys - for loop


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting unzip with subdirectorys - for loop
# 1  
Old 11-20-2009
unzip with subdirectorys - for loop

Hey!
I have some problems with unzip special files in subdirectorys. These Bash
Code:
unzip -j ./content.zip simages/062/06213/0621352.jpg -d ./images/
unzip -j ./content.zip simages/062/06213/0621356.jpg -d ./images/
unzip -j ./content.zip simages/062/06213/0621351.jpg -d ./images/
unzip -j ./content.zip simages/061/06143/0614334.jpg -d ./images/
unzip -j ./content.zip simages/061/06143/0614317.jpg -d ./images/
unzip -j ./content.zip simages/061/06143/0614329.jpg -d ./images/

is no problem

Code:
Archive:  ./content.zip
  inflating: ./images/0621352.jpg    
Archive:  ./content.zip
  inflating: ./images/0621356.jpg    
Archive:  ./content.zip
  inflating: ./images/0621351.jpg    
Archive:  ./content.zip
  inflating: ./images/0614334.jpg    
Archive:  ./content.zip
  inflating: ./images/0614317.jpg    
Archive:  ./content.zip
  inflating: ./images/0614329.jpg

But in a for loop:
Code:
for line in $(cat newimages.txt); do
strf=simages/`expr substr $line 1 3`/`expr substr $line 1 5`/$line
unzip -j ./content.zip $strf -d ./images/
done

it extracts only the last entry of the file:

Code:
Archive:  ./content.zip
caution: filename not matched:  simages/062/06213/0621352.jpg
Archive:  ./content.zip
caution: filename not matched:  simages/062/06213/0621356.jpg
Archive:  ./content.zip
caution: filename not matched:  simages/062/06213/0621351.jpg
Archive:  ./content.zip
caution: filename not matched:  simages/061/06143/0614334.jpg
Archive:  ./content.zip
caution: filename not matched:  simages/061/06143/0614317.jpg
Archive:  ./content.zip
inflating: ./images/0614329.jpg

The entrys in the txt file are:
Code:
0621352.jpg
0621356.jpg
0621351.jpg
0614334.jpg
0614317.jpg
0614329.jpg


Thanks for Help!

Last edited by vbe; 11-20-2009 at 05:54 AM.. Reason: rm URL (forum conformance)
# 2  
Old 11-20-2009
Can you echo $strf after the variable is created and remark this line

#unzip -j ./content.zip $strf -d ./images/

Just want to verify the string is exactly created and there are no extra CRLF etc ..

Last edited by chakrapani; 11-20-2009 at 06:37 AM..
# 3  
Old 11-20-2009
the link was exactly generated - i have see the link to my example files is not in my post ... ?

ok, here is it:

http://www.eecity.de/imgtest.tar.gz
# 4  
Old 11-20-2009
YES! THATS IT!
dos2unix -a newimages.txt

THANKS A LOT!!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Unzip

Hi All, I am having an error with a zip . It is showing me the below error. I tried using zip and jar command all show me the same error. Not sure what is this error and why this is coming any help ? >>> jar -xvf 99999_zpd.zip extracted: 100793_ipd0000.001.gz extracted:... (3 Replies)
Discussion started by: arunkumar_mca
3 Replies

2. Shell Programming and Scripting

Unzip the .zip file without using unzip utility in UNIX

I have .zip file, i want to list all the files archived in the zip file. unzip utility is not working for me in unix. Please help me resolve this issue Thanks ganesh. (3 Replies)
Discussion started by: Ganesh L
3 Replies

3. Shell Programming and Scripting

recursively going through folders and subdirectorys and running delete from crontab

Hio, So I have a crontab delete of older files setup. This script works fine if I run them by each individual directory. Problem is there are so many thousands of files and hundreds of directories and sub directories that I need to recursively have it go through and delete files by directory... (2 Replies)
Discussion started by: vsekvsek
2 Replies

4. SCO

Unzip

Hi, I have installed Unzip 5.3 on SCO Unix 5.05 Openserver and it successfully installs but when I go to unzip a file by using unzip <filename> I get ksh: unzip: not found . Any ideas?:o (1 Reply)
Discussion started by: twitchmaker
1 Replies

5. UNIX for Advanced & Expert Users

Unzip help

Hi, client is posting a zip file with named as "LM_SEEHERE_-_TMG_905678_20100504.zip". In zip file, inside we have 3 .csv files. how to unzip the file and client needs only "LM_SEEHERE_-_TMG_905678_20100504.csv" the other two files are products.csv,category.csv. They don't want these files... (2 Replies)
Discussion started by: kirankumar
2 Replies

6. Shell Programming and Scripting

How to Unzip a file using unzip utility for files zipped without zip utility ?

Hi, I need to zip/compress a data file and send to a vendor. The vendor does have only unzip utility and can accept only .ZIP files. I do not have zip utility in my server. How do I zip/compress the file so that it can be deflated using unzip command ? I tried gzip & compress commands, but... (1 Reply)
Discussion started by: Sabari Nath S
1 Replies

7. Shell Programming and Scripting

How to Unzip a .ZIP file in Unix without using unzip cmd..?????

Hi All I have ftped a .ZIP file (zipped using WinZip in Windows) to my Unix server (HP-UX). I don't have unzip cmd available in my curent Unix version Please let me know any cmd in UNIX (other than unzip) using which I can unzip this .ZIP file . Please elaborate on the commands aval and... (5 Replies)
Discussion started by: sureshg_sampat
5 Replies

8. Shell Programming and Scripting

Unzip, copy, and delete loop

Hey there, I am trying to move zipped text files from a remote server to a remote tape storage facility, through my home directory. What I want to do is get the zip file (using scp), unzip it, copy the output text file which was inside (using rfcp) to the tape storage server, and then delete... (3 Replies)
Discussion started by: spyne
3 Replies

9. HP-UX

How to Unzip a .ZIP file in Unix without using unzip cmd..?????

Hi All I have ftped a .ZIP file (zipped using WinZip in Windows) to my Unix server (HP-UX). I don't have unzip cmd available in my curent Unix version Please let me know any cmd in UNIX (other than unzip) using which I can unzip this .ZIP file . Please elaborate on the commands aval and... (5 Replies)
Discussion started by: sureshg_sampat
5 Replies

10. UNIX for Advanced & Expert Users

unzip

Is there any way to uncompress files in winzip/pkzip format which contain mulitple members without using the "unzip" command? (9 Replies)
Discussion started by: keroppi
9 Replies
Login or Register to Ask a Question