Hello,
I have a script that "validates" a ZIP file that look like this
My task is to compare its contents (i.e the list of files contained inside) with the control file that is provided inside the ZIP file itself.
Since we've started receiving files with spaces in their name, I prevented the OS from word splitting file names when I view the ZIP's contents like so
When I try to do the same with the control file,
SECOND_Array() correctly outputs the file names in the control files but it also output the file sizes listed in the control file
and my array comparison (diff -q) fails.
I tried adding this bit of Awk() code to remove the file size field but it brings word splitting back!
How can I remove the file size info and prevent word splitting? Any ideas?
Thank you.
I have a script that "validates" a ZIP file that look like this
Code:
AAA_20120801.zip =>
x~back end~20120801.TXT
y~time in~20120801.TXT
z~heat_chamber~20120801.TXT
AAA_20120801.ctl
Since we've started receiving files with spaces in their name, I prevented the OS from word splitting file names when I view the ZIP's contents like so
Code:
FIRST_Array=(); while read length date time filename; do FIRST_Array+=( "$filename" ); echo -e "$filename";
done < <(/usr/bin/unzip -qql AAA_20120801.zip)
Code:
SECOND_Array=(); while read filename; do SECOND_Array+=( "$filename" ); echo -e "$filename"; done < <(/usr/bin/unzip -p AAA_20120801.zip AAA_20120801.ctl )
Code:
x~back end~20120801.TXT 2KB
y~time in~20120801.TXT 2KB
z~heat_chamber~20120801.TXT 2KB
I tried adding this bit of Awk() code to remove the file size field but it brings word splitting back!
Code:
SECOND_Array=(); while read filename; do SECOND_Array+=( "$filename" ); echo -e "$filename"; done < <(/usr/bin/unzip -p AAA_20120801.zip AAA_20120801.ctl |awk '{print $1}')
How can I remove the file size info and prevent word splitting? Any ideas?
Thank you.