GLOB(1)                                                                GLOB(1)

       glob - expand glob expressions into matching filenames

       glob [-rsz] [-m mode] [globs]
       glob -f [-rsz] [-m mode] [files]
       glob -h
       glob -V

       The shell expands the wildcard character '*', '?', and the ranges spec-
       ified in square brackets '[' range ']' for most application without any
       issues.  When the shell can do the job you should use it.

       In  some  cases  the shell expands a glob into an argument list that is
       too long for execve(2).  In that case you get a nasty error like:
              ksh: ls: Argument list too long

       Glob outputs the matches on stdout, rather than as an argument  vector.
       Thus  any  number  of input globs may match a huge list of output file-
       names.  If the globs themselves will not fit on a command-line you  may
       use glob as a filter, then pass them in a file or on stdin.

       Note  that  when  multiple input patterns match the same filename, that
       name is replicated in the output.  Use oue(1l) to remove any  duplicate
       matches, as required.

       This  solves  the  overflow of the argument list issue when the matches
       are directed to xargs, xapply, or used as a co-process in a ksh script.
       See the EXAMPLE section below.

       If the program is called as glob then no options are forced.

              The glob expression are read as a filter would, rather than from
              command-line patterns.  This means you can pass them  on  stdin,
              or from a list of files as you would to cat(1).

              Print only a brief help message.

              All  matches must match the given instck(8l) mode specification.
              Both symbolic and octal modes are  allowed,  optional  bits  are
              represented  after  a slash.  See EXAMPLES below.  Always use -s
              (or -r) with this option, unless you have good reason not to.

              Report non-matching patterns on stderr, rather than passing them
              along unmatched.

              Unmatched  expressions  are  completely silent, the also ignores

              Show only the standerd version banner.
              Output names with terminating  NUL  characters,  like  find(1)'s
              -print0  option.   Also under -f reads names in the same format.
              If you want to input globs from a text file use tr as  a  filter
              (see below).

       glob /var/spool/mqueue/df/\* |&
              while read -p DF ; do
              Use  glob to list all the (possibly thousands) of messages pend-
              ing in sendmail's queue.  Then run a shell loop to process  each

       glob -s '*.[ch]' |xapply -f 'indent %1' -
              Run  the  indent(1)  program over all the C files in this direc-

       glob -f my.pats |xargs rm -f
              Remove all the files that match the glob expressions in my.pats.
              Remember the crazy eofstr in xargs(1) rules, look out for a file
              named underscore ("_").

       glob -s '*/*/*/' |xapply -P3 -f -5 'process' - - - - -
              Make a list of lots of subdirectories, send them to be process'd
              5  at  a time and run three of those in parallel.  This show the
              power gained my using xapply(1l) and glob together.   Note  that
              the last instance of process may have less than 5 arguments.

       glob -sf my.pats | oue | xargs rm --
              Remove  all  the files that match the globs, as above, but don't
              remove the same file more than once.

       glob -z -sf my.zpats | oue -z | xapply -zf 'rm -- "%q1"' -
              Same as the example above, but we think  where  might  be  crazy
              filenames  (like  ones with newline or spaces in them) so we use
              NUL termination in the whole pipeline.  See below.

       (glob '*.h' ; glob '*') | oue -vd
              Output all the (non-dot) files that do not match *.h.  There  is
              no better way to do this within glob itself.

       glob '*' | grep -v '\.h$'
              When you can translate the excluding glob into an RE you can use
              grep(1) inverse option to filter out the chaff.   This  is  less
              disk  intensive,  since  oue  may open a GDBM file in $TMPDIR to
              record the hits in the previous version.

       tr '\n' '\000' <my.pats | glob -zf | oue -z | xapply -zf 'rm -- "%q1"' -
              In the example above the file my.zpats has the globs  terminated
              with  NUL  characters.  In this example the file is a plain text
              file so we use tr(1) to convert it to NUL termination.

       glob -r '/var/backups/[1-9]???/*/*/*/' |xapply -P7 -fN fail-backups 'retain' -
              Because the expansion of this glob matches  backups  from  every
              year,  month,  day,  and  host  it is sometimes too long for the
              shell to process as an actual parameter to  xapply.   This  form
              allows  that very long list to be processed, and when no matches
              are found we are told about the error.

       glob -sm f200/7577 \*
              Output any  files  in  the  current  directory  that  are  owner
              writable.   This  is  handy  when  using rcs(1) to find possibly
              locked files.

       glob -sm f200/7577 \* .\*
              Include dot files in the above filter.

       glob -sm-200/7777 \* .\*
              Note that dash (-) may be substituted for the letter f, in which
              case  it  is less error-prone to abut the mode to the -m option.
              We also include the forced owner-write bit in the optional mask,
              which doesn't change the meaning at all.

       glob -s -m 'drwx??????' '*'
              Output  only the directories from the current directory that are
              open completely to their owner.

       glob -sm'crw-------' "/dev/*"
              Output only character special  files  which  are  restricted  to
              owner  only  access.   Note  the  -s option is important in this

       glob -m'crw-------' /dev/*
              (Note the missing quotes, and the missing -s option.)  The  most
              common  mistaken bug report is not protecting each of globs from
              expansion, then claiming that -m did not limit the output.   The
              output of non-matching patterns displays each non-matching path,
              as they were expanded by the shell on the command-line.

       You can't specify all the options  to  the  C  library  glob  function,
       that's  because they are not the same on every platform/implementation.

       Glob doesn't emulate busted csh(1) globs, but curly(1l) can pre-process
       the  curly  braces.   See uncurly(1l) for a program to compresses them,
       which is a great way to pack a list of files.

       There is no inverse filter, because the contents of the directory might
       change, thus causing more (fewer) matches than expected (input).

       KS Braunsdorf, NonPlayer Character Guild
       xapply at no spam treats

       instck(8l),  xapply(1l),  oue(1l),  xargs(1),  ksh(1),  csh(1),  tr(1),
       glob(3), curly(1l), uncurly(1l), gdbm(3), sendmail(8)

                                     LOCAL                             GLOB(1)