Back to home page

OSCL-LXR

 
 

    


0001 
0002 # This filter requires one command line option of form -vN=n
0003 # where n must be a decimal number.
0004 #
0005 # Repeat each input line containing $$ n times, replacing $$ with 0...n-1.
0006 # Replace each $# with n, and each $* with a single $.
0007 
0008 BEGIN {
0009   n = N + 0
0010 }
0011 {
0012   if (/\$\$/) { rep = n } else { rep = 1 }
0013   for (i = 0; i < rep; ++i) {
0014     tmp = $0
0015     gsub(/\$\$/, i, tmp)
0016     gsub(/\$#/, n, tmp)
0017     gsub(/\$\*/, "$", tmp)
0018     print tmp
0019   }
0020 }