Is it possible and how can I zip a symlink from a linux shell?
Asked
Active
Viewed 1.2e+01k times
2 Answers
104
You can store symlinks as symlinks (as opposed to a copy of the file/directory they point to) using the --symlinks or -y parameters of the zip program.
Assuming foo is a directory containing symlinks:
zip --symlinks -r foo.zip foo/
# or
zip -y -r foo.zip foo/
Which of the flags to use depends on your version of zip; more current versions may support both. Check zip --help or man zip to find the correct one for your situation.
Rar equivalent:
rar a -ol foo.rar foo/
tar stores them as is by default.
tar czpvf foo.tgz foo/
Note that the symlink occupies almost no disk space by itself (just an inode). It's just a kind of pointer in the filesystem, as you probably know.
Zilk
- 363
Eduardo Ivanec
- 15,281
13
On RHEL 5, we have
$ zip -h
Copyright (C) 1990-2005 Info-ZIP
Type 'zip "-L"' for software license.
Zip 2.31 (March 8th 2005). Usage:
zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
(snip)
-y store symbolic links as the link instead of the referenced file
nodakai
- 351