Skip to content

Instantly share code, notes, and snippets.

@cobanov
Created March 4, 2022 22:06
Show Gist options
  • Save cobanov/e135638bf3c197dd468e7fe16e7b7de0 to your computer and use it in GitHub Desktop.
Save cobanov/e135638bf3c197dd468e7fe16e7b7de0 to your computer and use it in GitHub Desktop.
# Basic Example
awk -F: '{print $1, $NF}' /etc/passwd
-F:|Colon as a separator
{...}|Awk program
print|Prints the current record
$1|First field
$NF|Last field
/etc/passwd|Input data file
# Variables
$0|Whole line
$1, $2...$NF|First, second… last field
NR|Total Number of Records
NF|Nnumber of Fields
OFS|Output Field Separator
FS|input Field Separator
ORS|Output Record Separator
RS|input Record Separator
FILENAME|Name of the file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment