|
Home > Archive > Unix Programming > September 2004 > Difference between remove and unlink
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Difference between remove and unlink
|
|
|
| What is the difference between unlink() and remove(). Assume i have a
file x and it has a hardlink y.
then what is the difference between
unlink("x");
remove ("x");
| |
| Erik Max Francis 2004-09-15, 10:36 am |
| ravi wrote:
> What is the difference between unlink() and remove(). Assume i have a
> file x and it has a hardlink y.
> then what is the difference between
> unlink("x");
> remove ("x");
unlink deletes files, rmdir deletes directories, remove deletes either.
man unlink
man remove
--
__ Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/
/ \ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
\__/ Then conquer we must, for our cause is just ...
-- Francis Scott Key
| |
| Stephane CHAZELAS 2004-09-15, 10:36 am |
| 2004-09-15, 00:35(-07), Erik Max Francis:
[...]
>
> unlink deletes files, rmdir deletes directories, remove deletes either.
[...]
And to do so, remove does a "lstat" on the file to find out if
it's a directory or not. That means that "remove" involves two
system calls (lstat and either unlink or rmdir). You can save
the "lstat" if you know the type of the file by advance by
calling directly unlink or rmdir.
--
Stephane
|
|
|
|
|