------------------------------------------------------------------------ next, continue, nextfile ------------------------------------------------------------------------ Ia. next is a powerful command in awk. next reads the next line and control jumps to the TOP OF THE PROGRAM. in contrast for "continue" the control simply goes to the top of the loop (in which continue is embedded). here is a typical example of the use of next awk -F: 'NF==1{print >"b"; next}; NF==2{print $1>"a"; print $2>"b"}' infile the infile has the form val1:vall2 val1 val1 val1:val2 (and so on) The idea is to stick write all val1 to "a" and val2 to "b". When NF=1 then we write to file "a" and there is no need to worry about writing to file "b". So next saves additional checks. with clever use of next you can improve the efficiency of your code. Ib. Another use of next is to prevent other actions if one action is take. This is not a matter of efficiency but of necessity. Say, you have a file "a" which calls for other files with lines starting with "\include{FILENAME}" $ cat a This is Hello Kitty \include{parvi} I am from Japan \include{rusty} I have heard of rabbits from the US Your goal is to write an awk script which prints normal lines but which print the contents of files when the program encounters "\include{FILE}" $ awk '/\include/{gsub(/^.+{/,"");gsub(/}$/,"");system("cat " $0);next}{print}' a So when a line with "\include" is found you wish to print the contents (you leave the heavy lifting to cat). But you also wish to print the input line for other lines. The use of next simplifies {if "/include" cat else print input line} logic. In fact the above one-line can be simplified to $ awk '/\include/{gsub(/^.+{/,"");gsub(/}$/,"");system("cat " $0)}1' a nextfile closes the current file and starts reading from the next file on the stack.