glob(3) Library Functions Manual glob(3) glob, globfree - glob() (libc -lc) #include int glob(const char *restrict pattern, int flags, typeof(int (const char *epath, int eerrno)) *errfunc, glob_t *restrict pglob); void globfree(glob_t *pglob); glob() pattern ( glob(7)). wordexp(3). globfree() glob(). glob() pglob. glob_t ( ) POSIX.2 ( ): typedef struct { size_t gl_pathc; /* */ char **gl_pathv; /* . */ size_t gl_offs; /* gl_pathv. */ } glob_t; . flags OR glob(): GLOB_ERR ( ). glob() . GLOB_MARK . GLOB_NOSORT . . . GLOB_DOOFFS pglob->gl_offs pglob->pathv. . GLOB_NOCHECK . glob() GLOB_NOMATCH . GLOB_APPEND glob(). glob(). GLOB_NOESCAPE ('\') . . flags GNU POSIX.2: GLOB_PERIOD . . GLOB_ALTDIRFUNC pglob->gl_closedir pglob->gl_readdir pglob->gl_opendir pglob->gl_lstat pglob->gl_stat . GLOB_BRACE csh(1) {a,b}. . "{foo/{,cat,dog},bar}" glob() : "foo/" "foo/cat" "foo/dog" "bar". GLOB_NOMAGIC . GLOB_TILDE . ('~') ('/') . ( "~andrea/bin") . . GLOB_TILDE_CHECK GLOB_TILDE. glob() GLOB_NOMATCH . GLOB_ONLYDIR glob() . . . ( .) errfunc NULL epath eerrno errno opendir(3) readdir(3) stat(2). errfunc GLOB_ERR glob() errfunc. pglob->gl_pathc pglob->gl_pathv . . glob() . GLOB_APPEND flags . GNU pglob->gl_flags GLOB_MAGCHAR . glob() . : GLOB_NOSPACE GLOB_ABORTED GLOB_NOMATCH . attributes(7). +----------------------+------------------------------------+----------+ | | | | +----------------------+------------------------------------+----------+ |glob() | | MT-Unsafe | | | | race:utent | | | | env | | | | sig:ALRM | | | | timer | | | | locale | +----------------------+------------------------------------+----------+ |globfree() | | MT-Safe | +----------------------+------------------------------------+----------+ utent race:utent setutent(3) getutent(3) endutent(3) . glob() race:utent . POSIX.1-2008. POSIX.1-2001, POSIX.2. gl_pathc gl_offs size_t glibc 2.1 POSIX.2 int glibc 2.0. glob() malloc(3) opendir(3). errno. ls -l *.c ../*.c : glob_t globbuf; globbuf.gl_offs = 2; glob("*.c", GLOB_DOOFFS, NULL, &globbuf); glob("../*.c", GLOB_DOOFFS | GLOB_APPEND, NULL, &globbuf); globbuf.gl_pathv[0] = "ls"; globbuf.gl_pathv[1] = "-l"; execvp("ls", &globbuf.gl_pathv[0]); ls(1), sh(1), stat(2), exec(3), fnmatch(3), malloc(3), opendir(3), readdir(3), wordexp(3), glob(7) 3 . . : . 6.18 8 2026 glob(3)