1READDIR(3am)               GNU Awk Extension Modules              READDIR(3am)
2
3
4

NAME

6       readdir - directory input parser for gawk
7

SYNOPSIS

9       @load "readdir"
10

DESCRIPTION

12       The readdir extension adds an input parser for directories.
13
14       When this extension is in use, instead of skipping directories named on
15       the command line (or with getline), they  are  read,  with  each  entry
16       returned as a record.
17
18       The record consists of three fields. The first two are the inode number
19       and the filename, separated by a forward slash character.   On  systems
20       where  the  directory  entry  contains  the file type, the record has a
21       third field which is a single letter indicating the type of the file: f
22       for  file,  d  for  directory,  b for a block device, c for a character
23       device, p for a FIFO, l for a symbolic link, s for a socket.
24
25       On systems without the file type information, the extension falls  back
26       to  calling  stat(2),  in  order  to provide the information.  Thus the
27       third field should never be u.
28
29       By default, if a directory cannot be opened (due  to  permission  prob‐
30       lems, for example), gawk will exit.  As with regular files, this situa‐
31       tion can be handled using a BEGINFILE rule that checks ERRNO and prints
32       an error or otherwise handles the problem.
33

EXAMPLE

35       @load "readdir"
36       ...
37       BEGIN { FS = "/" }
38       { print "file name is", $2 }
39

SEE ALSO

41       GAWK:   Effective   AWK   Programming,   filefuncs(3am),  fnmatch(3am),
42       fork(3am), inplace(3am),  ordchr(3am),  readfile(3am),  revoutput(3am),
43       rwarray(3am), time(3am).
44
45       opendir(3), readdir(3), stat(2).
46

AUTHOR

48       Arnold Robbins, arnold@skeeve.com.
49

COPYING PERMISSIONS

51       Copyright © 2012, 2013, 2018, 2019 Free Software Foundation, Inc.
52
53       Permission  is  granted  to make and distribute verbatim copies of this
54       manual page provided the copyright notice and  this  permission  notice
55       are preserved on all copies.
56
57       Permission  is granted to copy and distribute modified versions of this
58       manual page under the conditions for verbatim  copying,  provided  that
59       the  entire  resulting derived work is distributed under the terms of a
60       permission notice identical to this one.
61
62       Permission is granted to copy and distribute translations of this  man‐
63       ual page into another language, under the above conditions for modified
64       versions, except that this permission notice may be stated in a  trans‐
65       lation approved by the Foundation.
66
67
68
69Free Software Foundation          Oct 30 2019                     READDIR(3am)
Impressum