-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove.c
59 lines (53 loc) · 1.07 KB
/
remove.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
void swap(char **a, char **b)
{
char *c = *a;
*a = *b;
*b = c;
}
char **sort(char **tab)
{
int i = 1;
int j = 0;
while (tab[i]) {
for (j = i + 1; tab[j]; j++) {
if (strcmp(tab[i], tab[j]) < 0) {
swap(&tab[i], &tab[j]);
}
}
i++;
}
return tab;
}
void rm(char **av)
{
int i = 1;
char dest[1000] = "history -d ";
while (av[i]) {
strcat(dest, av[i]);
strcat(dest, " ");
i++;
}
system(dest);
}
void usage()
{
printf("USAGE\n");
printf("Tu fais \"history\" dans ton terminal pour voir le numéro des commandes que tu veux supprimer.\n");
printf("Ensuite tu fais:\n");
printf("./rm --toutes les commandes que tu veux supprimer\n");
printf("EXAMPLE\n");
printf("./rm 45 456 456 123 123\n");
}
int main(int ac, char **av)
{
system("history");
/*if (ac == 1 || (ac == 2 && strcmp(av[1], "-h") == 0)) {
usage();
return 84;
}
rm(av);*/
return 0;
}