1READDIR(3am) GNU Awk Extension Modules READDIR(3am)
2
3
4
6 readdir - directory input parser for gawk
7
9 @load "readdir"
10
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, and u
24 (unknown) for anything else.
25
26 On systems without the file type information, the third field is always
27 u.
28
30 On GNU/Linux systems, there are filesystems that don't support the
31 d_type entry (see readdir(3)), and so the file type is always u. You
32 can use the filefuncs extension to call stat() in order to get correct
33 type information.
34
36 @load "readdir"
37 ...
38 BEGIN { FS = "/" }
39 { print "file name is", $2 }
40
42 GAWK: Effective AWK Programming, filefuncs(3am), fnmatch(3am),
43 fork(3am), inplace(3am), ordchr(3am), readfile(3am), revoutput(3am),
44 rwarray(3am), time(3am).
45
46 opendir(3), readdir(3), stat(2).
47
49 Arnold Robbins, arnold@skeeve.com.
50
52 Copyright © 2012, 2013, Free Software Foundation, Inc.
53
54 Permission is granted to make and distribute verbatim copies of this
55 manual page provided the copyright notice and this permission notice
56 are preserved on all copies.
57
58 Permission is granted to copy and distribute modified versions of this
59 manual page under the conditions for verbatim copying, provided that
60 the entire resulting derived work is distributed under the terms of a
61 permission notice identical to this one.
62
63 Permission is granted to copy and distribute translations of this man‐
64 ual page into another language, under the above conditions for modified
65 versions, except that this permission notice may be stated in a trans‐
66 lation approved by the Foundation.
67
68
69
70Free Software Foundation Jan 15 2013 READDIR(3am)