sed in MacOS

1, use G command to add a new line

https://stackoverflow.com/questions/6111679/insert-linefeed-in-sed-mac-os-x/6112034

2, use parameter in substitution command

https://stackoverflow.com/questions/34969408/path-substitution-with-sed-and-shell-variables-on-os-x

dig +short baidu.com

sudo cp /etc/pf.conf /etc/pf.conf_bak`date +%Y%m%d%H%M%S`

output_cmd="pass out proto tcp from any to ${1} port ${2}"

sudo sed -i '' -e '${G;}' /etc/pf.conf

sudo sed -i '' -e "$ s/$/$output_cmd/" /etc/pf.conf

sudo pfctl -evf /etc/pf.conf