I have a series of zip archives from which I wish to extract one text file to an output directory. the file is in the general location:
archive.zip/archive/summary.txt
I have the following code that I thought should work:
for file in *.zip
do
name=${file##*/}
base=${name%.zip}
unzip -j $name/$base/summary.txt -d /$output/$file-summary.txt
done
However unzip cannot find the text files.
In the end the following did what I wanted:
for file in *.zip
do
name=${file##*/}
base=${name%.zip}
unzip -j "$name" "$base/summary.txt" -d "$output/$base"
done