home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


getline [var ] [< file ]
command | getline [var ]

Read next line of input. Original awk doesn't support the syntax to open multiple input streams. The first form reads input from file ; the second form reads the output of command . Both forms read one record at a time, and each time the statement is executed, it gets the next record of input. The record is assigned to $0 and is parsed into fields, setting NF , NR and FNR . If var is specified, the result is assigned to var , and $0 and NF aren't changed. Thus, if the result is assigned to a variable, the current record doesn't change. getline is actually a function and returns 1 if it reads a record successfully, 0 if end-of-file is encountered, and -1 if it's otherwise unsuccessful. {N}

Previous: Reference: function UNIX in a Nutshell: System V Edition Next: Reference: gensub
Reference: function Book Index Reference: gensub

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System