Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prevent word splitting with file with spaces in name 1

Status
Not open for further replies.

kristo5747

Programmer
Mar 16, 2011
41
US
Hello,

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
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

Code:
FIRST_Array=(); while read length date time filename; do FIRST_Array+=( "$filename" ); echo -e "$filename"; 
done < <(/usr/bin/unzip -qql AAA_20120801.zip)
When I try to do the same with the control file,

Code:
SECOND_Array=(); while read length date time filename; do SECOND_Array+=( "$filename" ); echo -e "$filename"; done < <(/usr/bin/unzip -c AAA_20120801.zip AAA_20120801.ctl )
SECOND_Array() ends up empty and my array comparison (diff -q) fails.

This is very bizarre since my control file has three records:
Code:
x~back end~20120801.TXT
y~time in~20120801.TXT
z~heat_chamber~20120801.TXT

How can prevent word splitting when I view the contents of the control file? Any ideas?

Thank you.
 
The control file seems to contain only filenames, so replace this:
while read length date time filename
with this:
while read filename

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
((Smacking forehead)) Duh! That was it.

Thank you!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top