<p>Is there a way to make <strong>awk</strong> (gawk) ignore or skip missing files? That is, files passed on the command line that no longer exist in the file system (e.g. rapidly appearing/disappearing files under /proc/[1-9]*).</p>

<p>By default, a missing file is a fatal error :-(</p>

<p>I would like to be able to do the equivalent of something like this:</p>

<pre><code>BEGIN { MISSING_FILES_ARE_FATAL = 0 }  # &lt;- Wishful thinking!
      { count++ }
END   { print count }
</code></pre>

<p>A wrapper script cannot check that files exist befor awk is run as they may disappear between the time they are checked and awk then tries to open them, i.e., it is a race condition. (It is also a race condition to check-and-then-open within awk, although the timing is tighter)</p>

In the finest of traditions, I will answer your awk question with a Perl program.
```
```
#!/usr/bin/perl -w

for my $file (@ARGV) {
    open my $fh, $file or next;
    while(<$fh>) {
        ...do your thing here...
    }
}
```
```
(It's not awk, but it is the only solution without a race condition.)