Created
July 9, 2014 00:12
-
-
Save washtubs/9f3747795e4f34522a70 to your computer and use it in GitHub Desktop.
multi-pass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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