1 1 2 # This filter requires one command line option 2 # This filter requires one command line option of form -vN=n 3 # where n must be a decimal number. 3 # where n must be a decimal number. 4 # 4 # 5 # Repeat each input line containing $$ n times 5 # Repeat each input line containing $$ n times, replacing $$ with 0...n-1. 6 # Replace each $# with n, and each $* with a s 6 # Replace each $# with n, and each $* with a single $. 7 7 8 BEGIN { 8 BEGIN { 9 n = N + 0 9 n = N + 0 10 } 10 } 11 { 11 { 12 if (/\$\$/) { rep = n } else { rep = 1 12 if (/\$\$/) { rep = n } else { rep = 1 } 13 for (i = 0; i < rep; ++i) { 13 for (i = 0; i < rep; ++i) { 14 tmp = $0 14 tmp = $0 15 gsub(/\$\$/, i, tmp) 15 gsub(/\$\$/, i, tmp) 16 gsub(/\$#/, n, tmp) 16 gsub(/\$#/, n, tmp) 17 gsub(/\$\*/, "$", tmp) 17 gsub(/\$\*/, "$", tmp) 18 print tmp 18 print tmp 19 } 19 } 20 } 20 }
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.