awk

From RaySoft

The awk utility is a data extraction and reporting tool that uses a data-driven scripting language consisting of a set of actions to be taken against textual data (either in files or data streams) for the purpose of producing formatted reports. The language used by awk extensively uses the string datatype, associative arrays (that is, arrays indexed by key strings), and regular expressions.[1]

Documentation

Syntax

awk [PARAMETER ...] [FILE ...]

Parameters

-F SEPARATOR, --field-separator SEPARATOR
Use SEPARATOR for the input field separator (the value of the FS predefined variable).

Examples

Get the FQHN using nslookup
nslookup 'xeon' | awk --field-separator ':  *' '/Name/{print $2}'

Output:

xeon.raysoft.loc
Sort a comma separated string ignoring the first char
sed 's/\n//g; s/, */\n/g' <<<'.foo, #bar, -bla' \
| sort --key='1.2' \
| awk '{printf("%s%s", sep, $0); sep=", "} END {print ""}'

Output:

#bar, -bla, .foo

References