Awk¶
- date
2020-12-25
- version
1
- Basic structure of an awk program:
In short, an Domain Specified Language for pattern matching.
pattern { action }
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, usefor
loop.{ for(c=0;c<50;c++) printf "-"; printf "\n" }
- Edit inplace:
-i inplace