Change the field separator in awk

awk -F  ":" '{print $1}'

# or if you want to do it programatically

awk 'BEGIN { FS=":" } { print $1 }'

# or you can also use a regular expression as a field separator.
# The following will print "bar" by using a regular expression to set the number "10" as a separator.

echo "foo 10 bar" | awk -F'[0-9][0-9]' '{print $2}'
Previous
Next