help-gawk
[Top][All Lists]
Advanced

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

Re: How do I determine the existence (or non-existence) of a file from a


From: Andrew J. Schorr
Subject: Re: How do I determine the existence (or non-existence) of a file from an AWK script?
Date: Tue, 11 Apr 2023 11:04:29 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

On Tue, Apr 11, 2023 at 02:07:23PM +0000, Alan Mackenzie wrote:
> Many thanks.  I've gone for your first solution, which should hopefully
> work in any POSIX conformant AWK, not just gawk.  It has the slight
> disadvantage of giving an error for a read only file, but I think it will
> be very rare for anybody to want to commit such a file with git.

Yes -- using getline to test whether you can read the file is the simplest and
most portable solution. Read-only files are not a problem, since you're just
trying to read. But if you don't have read permissions at all, that would
result in an error. But how can git commit a file that it can't read?

Regards,
Andy



reply via email to

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