aboutsummaryrefslogtreecommitdiffstats
path: root/awklib/eg/lib/readable.awk
blob: 6942dcca09d5f234faf24d73701398131ac370d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# readable.awk --- library file to skip over unreadable files
#
# Arnold Robbins, arnold@skeeve.com, Public Domain
# October 2000
# December 2010

BEGIN {
    for (i = 1; i < ARGC; i++) {
        if (ARGV[i] ~ /^[[:alpha:]_][[:alnum:]_]*=.*/ \
            || ARGV[i] == "-" || ARGV[i] == "/dev/stdin")
            continue    # assignment or standard input
        else if ((getline junk < ARGV[i]) < 0) # unreadable
            delete ARGV[i]
        else
            close(ARGV[i])
    }
}