Awk

date

2020-12-25

Basic structure of an awk program is pattern { action }, in short, an Domain Specified Language for pattern matching.

Pass shell variables into awk:

awk '{print $home}' home=$HOME

Use regular expression:

# (The regex must be enclosed by slashes(`/`), and comes after the operator)
/regex_pattern/ { print 1 }

Print remaining columns 1

{ $1=""; print $0 }

Print a character arbitrary times, printf is not possible to do this, use for loop:

{ for(c=0;c<50;c++) printf "-"; printf "\n" }

Edit inplace:

awk -i inplace
1

https://stackoverflow.com/a/2961994