shell command

awk

awk ‘{print}’ coins.txt
awk ‘{print $1}’ coins.txt
awk ‘{print $2}’ coins.txt
awk ‘{print $3}’ coins.txt
awk ‘{print $4}’ coins.txt
awk ‘{print $5}’ coins.txt
awk ‘{print $1,$2,$5}’ coins.txt
awk ‘{print $1 “\t” $2,$5}’ coins.txt
awk ‘{print $1 “\t” $2 “\t” $5}’ coins.txt
awk ‘{print NR “\t” $1 “\t” $2 “\t” $5}’ coins.txt
awk ‘{print NF $0}’ coins.txt
awk ‘{print NF “\t” $0}’ coins.txt
awk ‘{print NR “\t” $0}’ coins.txt
awk ‘{print NF “\t” $0}’ coins.txt
awk ‘$3=1981{print $0}’ coins.txt
awk ‘$1=”gold”{print $0}’ coins.txt
awk ‘$4=”American”{print $0}’ coins.txt
awk ‘NF=5{print $0}’ coins.txt
awk ‘{print $1, $2}’
awk ‘BEGIN{fs=”,”}{print $1, $2}’
awk ‘BEGIN{FS=”,”}{print $1, $2}’
awk ‘BEGIN{OFS=”,”}{print $1, $2}’
awk ‘BEGIN{OFS=”,”; FS=”,”}{print $1, $2}’
awk ‘BEGIN{OFS=”\t”; FS=”,”}{print $1, $2}’
awk ‘{ print NR, $0}’ coins.txt data.txt
awk ‘{ print NR, FILENAME, $0}’ coins.txt data.txt
awk ‘{ $3=”xxxx” print $0}’ coins.txt
awk ‘{ $3=”xxxx”; print $0}’ coins.txt
awk ‘{ print $-1}’ coins.txt
awk ‘{ print $NF}’ coins.txt
awk ‘{ print $(NF-1)}’ coins.txt
awk ‘{ print $(NR-1)}’ coins.txt
awk ‘{a=1;b=3; print a+b}’
awk ‘{a=1;b=3; print a b}’
awk ‘{a=1;b=3; print a+b}’
awk ‘{a=1;b=3;c=4; print a b+c}’
awk ‘/abc/{print $0}’ regex.txt
vim regex.txt
awk ‘/ac/{print $0}’ regex.txt
awk ‘/a.c/{print $0}’ regex.txt
awk ‘/a.c/{print $0}’ regex.txt
awk ‘/a\/c/{print $0}’ regex.txt
awk ‘/a\c/{print $0}’ regex.txt

sed

Leave a Reply

Your email address will not be published. Required fields are marked *