#include #include #include #include #include static char* pat; int filter(const struct dirent *ent) { struct stat statbuf; lstat(ent->d_name, &statbuf); int mat = fnmatch(pat, ent->d_name, FNM_PATHNAME | FNM_PERIOD); switch (mat) { case 0: return S_ISLNK(statbuf.st_mode); case FNM_NOMATCH: return 0; default: // Fehlerbehandlung } } int main(int argc, char **argv) { if (argc < 2) { // usage exit(1); } pat = argv[1]; struct dirent** ents; int n = scandir(".", &ents, filter, alphasort); // Fehlerbehandlung for (int i = 0; i < n; ++i) { printf("%s\n", ents[i]->d_name); // Fehlerbehandlung free(ents[i]); } free(ents); }