Operating System - HP-UX
1838653 Members
4361 Online
110128 Solutions
New Discussion

convert the files to .zip file

 
Mousa55
Super Advisor

convert the files to .zip file

Hello
how to convert any file in different extention in unix to .zip extention

and the unzip command where is extract the files?, only to the current directory!

thanks and best regards
5 REPLIES 5
Dennis Handly
Acclaimed Contributor

Re: convert the files to .zip file

This appears to be a duplicate of your other thread:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1130788

To unzip, you just use:
$ unzip foo.zip
Mousa55
Super Advisor

Re: convert the files to .zip file

hello
here is different question i need to how zip file not unzip. and the unzip were is saved the extract of the zip file?, if in the default directory how to save to file i am created
thanks
Yogeeraj_1
Honored Contributor

Re: convert the files to .zip file

hi,

unzip has the -d switch which you can use to specify the directory where you want to extrat the files.

below a quote from man unzip:

...
[-d exdir]
An optional directory to which to extract files. By default, all files and subdirectories are recreated in the current directory; the -d option allows extraction in an arbitrary directory (always assuming one has permission to write to the directory). This option need not appear at the end of the command line; it is also accepted before the zipfile specification (with the normal options), immediately after the zipfile specification, or between the file(s) and the -x option. The option and directory may be concatenated without any white space between them, but note that this may cause normal shell behavior to be suppressed. In particular, ``-d ~'' (tilde) is expanded by Unix C shells into the name of the user's home directory, but ``-d~'' is treated as a literal subdirectory ``~'' of the current directory.
...



hope this helps!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Steven Schweda
Honored Contributor

Re: convert the files to .zip file

Use the "zip" command? "zip -h".

zip [opts] archive.zip file1 file2 [...]

> [...] and the unzip were is saved the
> extract of the zip file?

Normally, Zip saves the (relative) path to a
file in the archive, and UnZip will recreate
that path when the file is extracted. For
example:

td176> ls -lR a b

a:
total 8
-rw-rw-rw- 1 antinode 513 5 May 28 08:35 a.txt

b:
total 8
-rw-rw-rw- 1 antinode 513 5 May 28 08:35 b.txt

td176> zip ab.zip a/a.txt b/b.txt
adding: a/a.txt (stored 0%)
adding: b/b.txt (stored 0%)

td176> mkdir unz

td176> cd unz

td176> unzip ../ab.zip
Archive: ../ab.zip
extracting: a/a.txt
extracting: b/b.txt

td176> ls -lR
total 16
drwxrwxrwx 2 antinode 513 4096 May 28 08:37 a
drwxrwxrwx 2 antinode 513 4096 May 28 08:37 b

./a:
total 8
-rw-rw-rw- 1 antinode 513 5 May 28 08:35 a.txt

./b:
total 8
-rw-rw-rw- 1 antinode 513 5 May 28 08:35 b.txt


Both Zip and UnZip have "-j" options which
prevent recording (Zip) or recreating (UnZip)
the directories in the paths to the files;

td176> rm -rf *

td176> ls -l
total 0

td176> unzip -j ../ab.zip
Archive: ../ab.zip
extracting: a.txt
extracting: b.txt

td176> ls -l
total 16
-rw-rw-rw- 1 antinode 513 5 May 28 08:35 a.txt
-rw-rw-rw- 1 antinode 513 5 May 28 08:35 b.txt


Many things are possible. It might help if
you could give an example of what you would
like to happen.
Patrick Wallek
Honored Contributor

Re: convert the files to .zip file

Please note that 'zip' and 'unzip' are NOT part of HP-UX by default. You HAVE to download and install them separately. I gave you the locations to find them in your other thread.