Skip to content

Instantly share code, notes, and snippets.

@washtubs
Created July 9, 2014 00:12
Show Gist options
  • Save washtubs/9f3747795e4f34522a70 to your computer and use it in GitHub Desktop.
Save washtubs/9f3747795e4f34522a70 to your computer and use it in GitHub Desktop.
multi-pass
# Note! this only works if you pass the input as a file
# so that it can be read by wc.
BEGIN{pass=1; num_passes=4}
NR==1 {
( "cat " FILENAME " | wc -l" ) | getline NL
}
# ...enter custom code blocks here...
{print pass,$0}
# Must be the last block
FNR==NL{
while ( ++pass <= num_passes ) {
ARGC++
ARGV[ARGIND+1] = FILENAME
nextfile
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment