Awk

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
评论

如果你有任何意见,请在此评论。 如果你留下了电子邮箱,我可能会通过 回复你。