I'm settling down to work through the suggestions so far, but I think I could usefully go into a bit more detail now that I've got a better idea of formatting etc. My apologies, I've been an occasional lurker for years but haven't barked before.
What I'm trying to do is take a pattern of some sort, and then to "hiccough" some (but not all) of the lines an indeterminate number of times. So on reflection- and my apologies for not being more explicit first time round- this might be a better example of the required output:
iptables -t nat -N outbound-DMZ iptables -t nat -A outbound-DMZ -o eth1.201 -j SNAT --to-source 90.145 +.84.155 iptables -t nat -A outbound-DMZ -o eth1.200 -j SNAT --to-source 90.145 +.84.155 iptables -t nat -A outbound-DMZ -j RETURN iptables -t nat -A POSTROUTING -j outbound-DMZ
where this shows that the repeated lines are typically in the middle of the block of text rather than at the beginning or end. One idea that occured to me was something like
$commands = &reinterpolate <<"EOF"; iptables -t nat -N outbound-DMZ foreach \$iface (keys \%ipAddress) { iptables -t nat -A outbound-DMZ -o \$iface -j SNAT --to-source \$ipA +ddress{\$iface} } iptables -t nat -A outbound-DMZ -j RETURN iptables -t nat -A POSTROUTING -j outbound-DMZ EOF
where &reinterpolate picks up the lines with and between braces and (eventually) applies eval(), but I can see that some of the suggestions are approaching that.
The system this would be running on is a minimal router, so if possible I'd like to avoid anything that isn't in a typical Linux distro.
MarkMLlIn reply to Re: hiccoughing here documents
by Anonymous Monk
in thread hiccoughing here documents
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |