I want to use ,^ as the field delimiter, as follows:
echo "hello,^my,^friend" | awk -F',^' '{print $2}'
The above command should return my. But actually it returns nothing, why? I cannot figure it out.
I want to use ,^ as the field delimiter, as follows:
echo "hello,^my,^friend" | awk -F',^' '{print $2}'
The above command should return my. But actually it returns nothing, why? I cannot figure it out.
In extended regular expressions, circumflex character's special meaning is preserved irrespective of its position in the entire expression unless it's quoted or inside a bracket expression, so you need to quote it.
$ echo "hello,^my,^friend" | awk -F',\\^' '{print $2}'
my
Compare BRE Expression Anchoring to ERE Expression Anchoring.