help-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to continue upon encountering nonexistent input files?


From: Andrew J. Schorr
Subject: Re: How to continue upon encountering nonexistent input files?
Date: Fri, 25 Feb 2022 14:32:26 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

On Fri, Feb 25, 2022 at 01:23:10PM -0600, Peng Yu wrote:
> $ awk -e '{ print }' x.txt <(builtin printf '%s\n' {1..3})awk: fatal:
> cannot open file `x.txt' for reading: No such file or directory
> 
> As shown above, the above command stops when a nonexistent file is
> encountered. Is there a way to let awk keep on proceeding (but allows
> a way to handle the error in the awk code, e.g., print a customized
> error message)?

Please use a BEGINFILE rule, described in the docs:

https://www.gnu.org/software/gawk/manual/html_node/BEGINFILE_002fENDFILE.html

Regards,
Andy



reply via email to

[Prev in Thread] Current Thread [Next in Thread]