Renaming file within zip archives
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix administration > Renaming file within zip archives




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Renaming file within zip archives  
khoa nguyen


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-07-05 01:48 AM

Hi,

I would like to zip from stdin, e.g. through some pipe, into a zip
archive. When I unzip the file I would get "./-" as the unzipped file.
I'd like to unzip to some other logical name and not "./-".

For example,

[begin scenario]
% echo 'hello world' | zip > hello.zip
% unzip hello.zip
[end scenario]

unzipping hello.zip will produce a "./-" file.

Thanks in advance,
Khoa.





[ Post a follow-up to this message ]



    Re: Renaming file within zip archives  
Ulrich Hobelmann


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-07-05 01:48 AM

khoa nguyen wrote:
> Hi,
>
> I would like to zip from stdin, e.g. through some pipe, into a zip
> archive. When I unzip the file I would get "./-" as the unzipped file.
> I'd like to unzip to some other logical name and not "./-".
>
> For example,
>
> [begin scenario]
> % echo 'hello world' | zip > hello.zip
> % unzip hello.zip
> [end scenario]
>
> unzipping hello.zip will produce a "./-" file.

Zip is a container format, like tar.  It can contain more than one
file, so zipping from standard input would be difficult.

If you just want to zip one file, use gzip instead.  With
parameter -9 it has much better compression, too.
% cat foo.txt | gzip -9 > foo.txt.gz
% gunzip foo.txt.gz





[ Post a follow-up to this message ]



    Re: Renaming file within zip archives  
qazwart


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-07-05 11:11 PM

The "zip" command contains files and not strings. You're getting the
"-" because you're attempting to zip from STDIN, and not pass the "zip"
command a file to zip.

Like "tar", "zip" can operate on STDIN and STDOUT if you give it a "-"
for a filename.

For example:

zip -r - . |  | dd of=/dev/nrst0 obs=16k

Would produce a zip archive directly to tape device /dev/nrst0

Since most compression algorithims depend upon the entire file to work,
I'm not too sure if a utility that does exactly what you want exists.

I've tried what you did, but can't seem to get it to compress the
string "hello world". You can try the "zcat" command on "hello.zip" to
see if it will print out the string "hello world", but I'm not too sure
it will work.






[ Post a follow-up to this message ]



    Re: Renaming file within zip archives  
khoa nguyen


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-11-05 01:48 AM

> Since most compression algorithims depend upon the entire file to work,
> I'm not too sure if a utility that does exactly what you want exists.

I'm sending files to windows machines. The problem is that windows
does not like downloaded files with multiple extensions, e.g.
"foo.txt.gz". That's why I resort to zipping from stdin. And
perhaps...rename "-" to "foo.txt"?

The alternative is:

% echo "hello world" > foo.txt
% zip foo foo.txt

> I've tried what you did, but can't seem to get it to compress the
> string "hello world". You can try the "zcat" command on "hello.zip" to
> see if it will print out the string "hello world", but I'm not too sure
> it will work.

I think "hello world" is too small a string to illustrate any amount
of compression at all. If you zip larger files the amount of
compression will be more appreciable.

"zcat" does print out "hello world".

Thanks for all your replies,
Khoa.





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 07:20 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register