18c2ecf20Sopenharmony_ci 28c2ecf20Sopenharmony_ci# This filter requires one command line option of form -vN=n 38c2ecf20Sopenharmony_ci# where n must be a decimal number. 48c2ecf20Sopenharmony_ci# 58c2ecf20Sopenharmony_ci# Repeat each input line containing $$ n times, replacing $$ with 0...n-1. 68c2ecf20Sopenharmony_ci# Replace each $# with n, and each $* with a single $. 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ciBEGIN { 98c2ecf20Sopenharmony_ci n = N + 0 108c2ecf20Sopenharmony_ci} 118c2ecf20Sopenharmony_ci{ 128c2ecf20Sopenharmony_ci if (/\$\$/) { rep = n } else { rep = 1 } 138c2ecf20Sopenharmony_ci for (i = 0; i < rep; ++i) { 148c2ecf20Sopenharmony_ci tmp = $0 158c2ecf20Sopenharmony_ci gsub(/\$\$/, i, tmp) 168c2ecf20Sopenharmony_ci gsub(/\$#/, n, tmp) 178c2ecf20Sopenharmony_ci gsub(/\$\*/, "$", tmp) 188c2ecf20Sopenharmony_ci print tmp 198c2ecf20Sopenharmony_ci } 208c2ecf20Sopenharmony_ci} 21