shell-whiz-toolkit/awk
2024-10-16 14:34:03 +09:00
..
file_directory_example.awk add things resources from the last 5 years over machines 2024-10-15 09:59:09 +09:00
for_loop.awk add things resources from the last 5 years over machines 2024-10-15 09:59:09 +09:00
math1.awk add things resources from the last 5 years over machines 2024-10-15 09:59:09 +09:00
math2.awk add things resources from the last 5 years over machines 2024-10-15 09:59:09 +09:00
README.md move shell scripts and zsh and add fav vscode themes 2024-10-16 14:34:03 +09:00
TIPS.txt add things resources from the last 5 years over machines 2024-10-15 09:59:09 +09:00

awk


data manipulation


  • print elements in the column 3 that has the word "good" in the other columns
$ awk '/good/ { print $3 }' inventory
  • syntax:
$ awk -f {PROGRAM FILE} FILENAME
  • awk program is:
PATTERN{
  ACTION 1
  ACTION 2
  ACTION 3
}

with

. (Dot) Match any character
* Match zero or more character
^ Match beginning of line
$ Match end of line
\ Escape character following
[ ] List
{ } Match range of instance
+ Match one more preceding
? Match zero or one preceding
| Separate choices to match


if condition


if (condition)
{
  Statement 1
  Statement 2
  Statement N
  if condition  is TRUE
}
else
{
  Statement 1
  Statement 2
  Statement N
  if condition is FALSE
}