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.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communitySince 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).