#to look at traffic at port 80, in ascii format(-A), snaplen unlimited(-s 0)
tcpdump -i any -s 0 -A tcp port 80
#randomly select N lines from
shuf -n N input > output
#removing/selecting non-ascii chars
sed 's/[\d128-\d255]//' input_file
grep -P '[\x80-\xFF]' input_file
# Printing control character on shell (for example to use as delimiter in cut command)
Type Ctrl-v and then Ctrl-a will print ^A
# cat -n prints line numbers as well
//Note that cut command does not order the fields even if you say -f2,1 .They will still be printed in the order they appear in the input file. You can use awk for that
# cat data
1,2
3,4
# cut -d ',' -f2,1 data
1,2
3,4
# awk 'BEGIN { FS = "," } { print \$2,\$1}' data
2 1
4 3
#pretty-print json
echo '{"a":1,"b":2}' | python -mjson.tool
# Redirect stderr to stdout and stdout to a file
foo > log_file 2>&1
#convert seconds since epoch to date string
date -d @1396324799