change vim as default editor

 add the following to your shell configuration (probably `~/.bashrc`):

    export VISUAL=vim
    export EDITOR="$VISUAL"

or

sudo update-alternatives --config editor

link:  https://unix.stackexchange.com/questions/73484/how-can-i-set-vi-as-my-default-editor-in-unix

change interface name in Ubuntu

To rename interface eth0 to wan0, edit /etc/udev/rules.d/70-persistent-net.rules file and change

NAME="eth0" to NAME="wan0"

.

# PCI device 0x11ab:0x4363 (sky2)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*",
ATTR{address}=="00:00:00:00:00:00",ATTR{dev_id}=="0x0", ATTR{type}=="1",
KERNEL=="eth*", NAME="wan0"

link: https://www.shellhacks.com/change-network-interface-name-eth0-eth1-eth2/

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