To define multiple field separators with gawk, set the FS variable with the appropriate regex.
For example, to use comma(,), colon(:) and equal-to (=) as field separators, following can be used
cat file.txt | gawk '{FS = "[:,=]+"} {print $3" "$5}'
The above example also prints the 3rd and 5th field elements.
1 comment:
This became pretty handy. Thanks
Post a Comment