Skip to main content
fix logic error
Source Link
glenn jackman
  • 248.7k
  • 42
  • 233
  • 362

A more "awk-ish" way to write smcameron's answer:

awk 'NR-v n=5 '1; NR % 5n == 0 {print ""} 1' myfile' 

The trailing "1""1;" is a condition that is always true, and will trigger the default action which is to print the current line.

A more "awk-ish" way to write smcameron's answer:

awk 'NR % 5 == 0 {print ""} 1' myfile 

The trailing "1" is a condition that is always true, and will trigger the default action which is to print the current line.

A more "awk-ish" way to write smcameron's answer:

awk -v n=5 '1; NR % n == 0 {print ""}' 

The "1;" is a condition that is always true, and will trigger the default action which is to print the current line.

Source Link
glenn jackman
  • 248.7k
  • 42
  • 233
  • 362

A more "awk-ish" way to write smcameron's answer:

awk 'NR % 5 == 0 {print ""} 1' myfile 

The trailing "1" is a condition that is always true, and will trigger the default action which is to print the current line.