2009-10-16 09:25:19 +04:00
|
|
|
|
|
|
|
# This filter requires one command line option of form -vN=n
|
|
|
|
# where n must be a decimal number.
|
|
|
|
#
|
|
|
|
# Repeat each input line containing $$ n times, replacing $$ with 0...n-1.
|
|
|
|
# Replace each $# with n, and each $* with a single $.
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
n = N + 0
|
|
|
|
}
|
|
|
|
{
|
|
|
|
if (/\$\$/) { rep = n } else { rep = 1 }
|
|
|
|
for (i = 0; i < rep; ++i) {
|
|
|
|
tmp = $0
|
|
|
|
gsub(/\$\$/, i, tmp)
|
2019-12-06 18:26:00 +03:00
|
|
|
gsub(/\$#/, n, tmp)
|
2009-10-16 09:25:19 +04:00
|
|
|
gsub(/\$\*/, "$", tmp)
|
|
|
|
print tmp
|
|
|
|
}
|
|
|
|
}
|