awk
Linux · Text · available in the simulator
What it does
Processes text by fields and rules.
Syntax
awk [opciones] 'programa' [archivo...]
Options and parameters
-FSets the input field separator.
awk -F: '{print $1}' /etc/passwd-vAssigns a variable value before program execution.
awk -v n=3 '{print $n}' datos.txt-fReads the program source from a file.
$1References the first field of each record; $0 is the entire record.
awk '{print $1, $3}' datos.txtNRCurrent record number.
awk 'NR>1' datos.csvNFNumber of fields in the current record.
Usage examples
awk '{print $1}' archivoawk -F: '{print $1}' /etc/passwdawk -v n=3 '{print $n}' datos.txtawk '{print $1, $3}' datos.txtawk 'NR>1' datos.csv