LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-26-2012, 08:10 PM   #1
p3achyn3rd
LQ Newbie
 
Registered: Jun 2012
Posts: 1

Rep: Reputation: Disabled
Compression Utility command for symbolic links


Can someone please help. I am trying to find out the following command and if what I have is correct...

Directions: Compress the symbolic link /root/sfile using the compress utility and display the compression ratio...

My question: Is the symbolic link just "sfile" or does the entire directory need to be executed as well?

What I THINK it is:
compress -v -f -r /root/sfile

Can someone please confirm this for me??

Thank you so much!
 
Old 06-27-2012, 02:17 AM   #2
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203
Hi there,

A couple of comments on this.

A symbolic link itself can't be compressed. A symbolic link is just a pointer to another file, and doesn't contain any data itself (other than the target file name), so there isn't really anything to compress.

If this is on Linux, compress may not be your best compression tool to use. I say this because it is not installed by default on many linux distros because of historic patent issues with the underlying LZW algorithm, and because other tools like gzip and bzip2 offer better compression ratios.

For many linux tools, if you try and use them on a symbolic link, they will follow the link and operate on the target file. This does not apply to gzip and bzip2, though - these tools produce an error when you try and compress a symbolic link. I haven't tested this, but expect compress to act in the same way. If you want to compress the destination file, you would therefore have to specify its name as argument for most compression tools.

To answer your question:
Quote:
Is the symbolic link just "sfile" or does the entire directory need to be executed as well?
This depends on your current working directory. If you are in the /root directory, either usage ("/root/sfile" or just "sfile") will work. If you are in a different directory, you will have to specify the full path ("/root/sfile"). If you're not doing this interactively (i.e. are doing it from a script, or answering an academic question), it's always better to specify the full path to be safe.

Regarding your proposed solution:
Quote:
What I THINK it is:
compress -v -f -r /root/sfile
The "-v" option will display the compression ratio as requested. The "-f" will force compression, even if the compressed file isn't smaller than the original. If you are compressing a regular file, and this is what you want, by all means use it. I don't believe this will work on a symbolic link, though. I'm not sure what the "-r" option is mean to do?

I hope this helps!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Trying to write a command line script that will make symbolic links dave247 Programming 5 10-21-2010 12:24 PM
Problem with installpkg - external compression utility gzip missing samkz Slackware 5 04-20-2009 12:48 AM
how ls command finds symbolic links venmugil Linux - General 6 12-01-2008 12:58 PM
Symbolic links Vs Hard links sulekha Linux - General 2 10-02-2008 07:03 AM
how to use Find Command for Symbolic links nofunyet Linux - Newbie 2 04-08-2005 03:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration