O'Reilly logo

Learning AWK Programming by Shiwang Kalkhanda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Closing files and pipes

If the same filename or the same shell command is used more than once during AWK program execution, the file is opened for the first time only. The file is opened and the first record is read from that file, subsequently if the same file is used then another record is read from it and so on.

So, in order to re-read that file from the beginning, it becomes necessary to close that file first. The close() function makes this possible .The close(expr) function is used to close a file or pipe referenced using expr. The string value of expr should be the same as the string used to create/open the file or pipe used. Closing of files is necessary if we want to write a file and use it later in the same program. The operating ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required