awk multiple delimiters code example

Example: awk multiple delimiters

# Basic syntax:
awk -F'[:/|]' '{print $field#, $field#, ...}' input_file
# Where:
#	- : / and | are the three field delimiters considered
#	- $field# is the field nuber to be printed based on the splits made
#		by any of the delimiters

# Example usage:
# Say you have a file that contains the following lines and you want to
# extract the dir#, the file #, and the URL:
/logs/dir1/file_1 = demo.example.com
/logs/dir2/file_7 = quest.example.com
/logs/dir3/file_5 = www.example.com

# Running:
awk -F'[/_=]' '{print $3, $5, $6}' input_file

# Returns:
dir1	1	demo.example.com
dir2	7	quest.example.com
dir3	5	www.example.com

# *Note, each character contained in the braces [ ] is treated as a 
#	separate delimiter