{"id":368,"date":"2008-08-05T12:45:52","date_gmt":"2008-08-05T11:45:52","guid":{"rendered":"http:\/\/west-penwith.org.uk\/blog\/?p=368"},"modified":"2014-04-11T18:29:08","modified_gmt":"2014-04-11T17:29:08","slug":"zip-and-pipe","status":"publish","type":"post","link":"https:\/\/west-penwith.org.uk\/blog\/archives\/368","title":{"rendered":"zip and pipe"},"content":{"rendered":"<p>A little job I had to do today was to write a script (unix) to zip a file before transmitting it to a Windows system. No problem, we have zip installed&#8230;<\/p>\n<p><code>zip file.zip file.txt<\/code><\/p>\n<p>Then they decided that it was in ASCII Latin1 and they wanted it in UTF-8. Again, no problem<\/p>\n<p><code>iconv -f ISO-8859-1 -t UTF-8 file.txt | zip file.zip -<\/code><\/p>\n<p>The snag is that zip includes not only the compressed file in the output, but also headers giving details of the file name etc. In the case above the input comes from a pipe and there is no file name so it creates an entry called <code>-<\/code> (just a hyphen) which is not very useful. The unix <code>unzip<\/code> command has an option to get around this.<\/p>\n<p><code>unzip -p file.zip > file.utf8<\/code><\/p>\n<p>or you can use <code>funzip<\/code> if your implementation includes it.\n<\/p>\n<p><code>funzip file.zip > file.utf8<\/code><\/p>\n<p>I have no idea what they can do on Windows. I may have to do it the slow way and create an intermediate file with all the housekeeping, security and management that involves \ud83d\ude41<\/p>\n<p>Exercise for the reader: If you just unzip <code>file.zip<\/code> from above it creates a file called <code>-<\/code>. How do you do anything with it?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A little job I had to do today was to write a script (unix) to zip a file before transmitting it to a Windows system. No problem, we have zip installed&#8230; zip file.zip file.txt Then they decided that it was in ASCII Latin1 and they wanted it in UTF-8. Again, no problem iconv -f ISO-8859-1 [&hellip;]<\/p>\n","protected":false},"author":239,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-368","post","type-post","status-publish","format-standard","hentry","category-technical"],"_links":{"self":[{"href":"https:\/\/west-penwith.org.uk\/blog\/wp-json\/wp\/v2\/posts\/368","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/west-penwith.org.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/west-penwith.org.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/west-penwith.org.uk\/blog\/wp-json\/wp\/v2\/users\/239"}],"replies":[{"embeddable":true,"href":"https:\/\/west-penwith.org.uk\/blog\/wp-json\/wp\/v2\/comments?post=368"}],"version-history":[{"count":6,"href":"https:\/\/west-penwith.org.uk\/blog\/wp-json\/wp\/v2\/posts\/368\/revisions"}],"predecessor-version":[{"id":374,"href":"https:\/\/west-penwith.org.uk\/blog\/wp-json\/wp\/v2\/posts\/368\/revisions\/374"}],"wp:attachment":[{"href":"https:\/\/west-penwith.org.uk\/blog\/wp-json\/wp\/v2\/media?parent=368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/west-penwith.org.uk\/blog\/wp-json\/wp\/v2\/categories?post=368"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/west-penwith.org.uk\/blog\/wp-json\/wp\/v2\/tags?post=368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}