Link to home
Start Free TrialLog in
Avatar of jacobselvin
jacobselvin

asked on

difference between unlink and rm

Hi,
     I have a normal file which is NOT a soft/hard link. When I say unlink <file name> the file gets removed. Can somebody explain this behaviour? Since the file gets removed is it equalent to rm <file name>.
     I'm writing a bourne shell script where I have check for only the softlinks and remove it. How do I do it?
Thanx in advance,
- Jacob
ASKER CERTIFIED SOLUTION
Avatar of yuzh
yuzh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
if you unlink a file both the pointer and destination still exist except you can't see them

for example if /opt/softwareinstall is linked to /extradiskspace/app1

when you cd to  /opt/softwareinstall you will see everything in  /extradiskspace/app1  

if you remove this link then you will have to go to  /extradiskspace/app1  to see the same files and /opt/softwareinstall will be empty

Be very careful when using unlink if there are dependencies and you unlink you could run into major problems
Avatar of chris_calabrese
chris_calabrese

Think of unlink as the "raw" version of rm - rm gives you more control over things like properly removing directories, recurive directory removal, error-checking, etc.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial