Add unlink
This commit is contained in:
parent
32dc6db40b
commit
7f2ce1314e
1 changed files with 24 additions and 0 deletions
24
c/unlink.c
Normal file
24
c/unlink.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Not enough arguments.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
int code = unlink(argv[i]);
|
||||
if (code == -1) {
|
||||
perror(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Compilation: cc unlink.c -o unlink
|
||||
// Usage: ./unlink FILES ...
|
||||
// License: CC-0
|
Loading…
Reference in a new issue