This commit is contained in:
Your Name 2023-10-13 19:33:48 +03:00
parent 7eed71d9b2
commit 0e21d3939c
2 changed files with 53 additions and 0 deletions

15
TODO Normal file
View File

@ -0,0 +1,15 @@
chmod
chown
printf
shuf
id
ln
cp
shred
du
df
dd
nice
nohup
mktemp
test

38
coreutils/sleep.c Normal file
View File

@ -0,0 +1,38 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
int main(const int argc, const char **argv) {
if (argc == 1) {
printf("sleep [num[m - minute / h - hour / d - days].. ] / [inf (infinity)]\n");
return 0;
}
if (!strcmp(argv[1], "inf"))
for (;;)
sleep(1);
unsigned int sec = 0;
for (int i = 1; i < argc; i++) {
switch (argv[i][strlen(argv[i]) - 1]) {
case 'd':
sec += atoi(argv[i]) * 86400;
break;
case 'h':
sec += atoi(argv[i]) * 3600;
break;
case 'm':
sec += atoi(argv[i]) * 60;
break;
default:
sec += atoi(argv[i]);
}
}
sleep(sec);
return 0;
}