blob: 0809805a7e231809387902b825fb2d89e7c43bd0 [file] [log] [blame]
Vladimir Dronnikovdce3a7a2009-10-16 16:25:19 +11001
2# This filter requires one command line option of form -vN=n
3# where n must be a decimal number.
4#
5# Repeat each input line containing $$ n times, replacing $$ with 0...n-1.
6# Replace each $# with n, and each $* with a single $.
7
8BEGIN {
9 n = N + 0
10}
11{
12 if (/\$\$/) { rep = n } else { rep = 1 }
13 for (i = 0; i < rep; ++i) {
14 tmp = $0
15 gsub(/\$\$/, i, tmp)
Greg Kroah-Hartman4d1f99a2019-12-06 16:26:00 +010016 gsub(/\$#/, n, tmp)
Vladimir Dronnikovdce3a7a2009-10-16 16:25:19 +110017 gsub(/\$\*/, "$", tmp)
18 print tmp
19 }
20}