AWK basics

Printing columns

Print all the columns:

$ awk '{print $0}' FILE

Print the 1 column:

$ awk '{print $1}' FILE

Print the last column:

$ awk '{print $NF}' FILE

Print multiple columns:

$ awk '{print $1 $3}' FILE

Specifying field separator

By default, awk uses space and tab as field separator. You can specify how fields are separated using the -F option.

$ awk -F "/" '{print $1}' FILE

Excluding columns

Print all the columns but not the 2 one:

$ awk '{$2=""; print $0}' FILE

Print all the columns but not 1 and 2:

$ awk '{$1=$2=""; print $0}' FILE

 

Flushing iptables

You can flush and reset iptables to default running these commands:

iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

The -F command flushes all the chains and -X deletes empty (non-default) chains.
You can also create a script:Continue reading