Anonymous user
Check that file exists: Difference between revisions
→{{header|AWK}}
No edit summary |
|||
Line 126:
=={{header|AWK}}==
{{works with|gawk}}
<lang awk>@load "filefuncs"
BEGIN {
exists("input.txt")
exists("/input.txt")
exists("docs")
exists("/docs")
}
function exists(name ,fd) {
if ( stat(name, fd) == -1)
print name " doesn't exist"
else
print name " exists"
}</lang>
Getline method. Also works in a Windows environment.
<lang AWK>
# syntax: GAWK -f CHECK_THAT_FILE_EXISTS.AWK
|