1

I have the data as below:

p_id^|^data1^|^data2^|^data3

I need to get the 2nd field only

data1

Tried multiple tricks with awk command, but unable to find it out. Can someone please help.

1 Answer 1

4

Since the separator contains more than one character and all of them are special (both ^ and | are regular expression operators), you need to escape them. On the command line, you would do this with

awk -F '\\^\\|\\^' '{ print $2 }' file

You need the double backslashes to escape the backslashes themselves too (for a different reason).

1
  • Thank you ! Great Help !
    – PriB
    Dec 26, 2019 at 12:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .