REMOVE(3POSIX)
π REMOVE(3POSIX) β the POSIX Programmer's Manual page, but make it cute π
okay bestie, so this page lives in the POSIX Programmer's Manual (yes, the real one, REMOVE(3POSIX)), and I'm about to give you the whole thing with the vibe it deserves. no skips, no "tl;dr", we're going the whole way π«Ά
πΈ PROLOG πΈ
so like, heads up before we even start: this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ β like, actually differ β so go consult the corresponding Linux manual page for the deets on Linux behavior. orrrr the interface might not even be implemented on Linux at all. fun! π that's just how it is.
β¨ NAME β¨
remove β remove a file. that's it. that's the whole name section. iconic brevity.
π SYNOPSIS π
#include <stdio.h>
int remove(const char *path);
look at that. clean. gorgeous. path is a const char *, the return type is int, and the header is <stdio.h> β not <unistd.h>, not <stdlib.h>, <stdio.h. remember that, it's giving "surprise, file removal lives with the I/O girlies" π
π DESCRIPTION π
first things first, and this is important: the functionality described on this reference page is aligned with the ISO C standard. if there's any conflict between the requirements described here and the ISO C standard, that conflict is unintentional β nobody did that on purpose. and this volume of POSIX.1β2017 defers to the ISO C standard. so like, ISO C is the authority here, we're just vibing alongside it. π
now, what does remove() actually do? it shall cause the file named by the pathname pointed to by path to be no longer accessible by that name. poof. gone from that name. and a subsequent attempt to open that file using that name shall fail β unless it is created anew. (so if you make it again, it exists again. the name is free real estate. π)
here's the split that matters, and it's lowkey the whole personality of this function:
- if
pathdoes not name a directory, thenremove(path)shall be equivalent tounlink(path). - if
pathdoes name a directory, thenremove(path)shall be equivalent tormdir(path).
so it's like a little switchboard β file, directory, whichever, remove() picks the right call for you. main character energy fr fr π¦
π₯ RETURN VALUE π₯
bestie, this section has exactly one job and it's to point you elsewhere: refer to rmdir() or unlink(). that's the whole thing. go read those. π
π ERRORS π
same deal: refer to rmdir() or unlink(). the errors are whatever those two say they are. no new lore here.
and then, the little note that closes it out: the following sections are informative. yep β everything after this point is informative, not normative. keep that in mind for the rest of the page. β
π EXAMPLES π
π· Removing Access to a File π·
okay so the example is literally called "Removing Access to a File" and it shows you how to remove access to a file named /home/cnd/old_mods. here's the code, verbatim, because we do not touch code in this house:
#include <stdio.h>
int status;
...
status = remove("/home/cnd/old_mods");
see that ...? that's you, living your life, doing your thing, and then boom β status = remove("/home/cnd/old_mods"); and the name is free. status catches whatever comes back. slay. β¨
π APPLICATION USAGE π
None.
literally. that's the section. nothing to add, no notes, perfect, periodt. π
π§ RATIONALE π§
None.
the rationale girlies took the day off. honestly? respect. π
π FUTURE DIRECTIONS π
None.
no plans, no drama, no upcoming changes. the future is a blank little canvas and remove() is not on it. π
π SEE ALSO π
rmdir()unlink()
and also! The Base Definitions volume of POSIX.1β2017, <stdio.h> β that's where the header lives, go say hi. πΈ
π COPYRIGHT π
okay legal bestie moment, gotta say it properly:
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
and also this lil disclaimer: any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie!! from the IEEE/The Open Group, 2017 girlies who brought you REMOVE(3POSIX) β mwah, go forth and remove() responsibly π«Άπ
β¨
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms