echo "A:\ B:\ C:\ D:\" | awk -F'[:\]' '{print $1}'
Output:
awk: warning: escape sequence `\]' treated as plain `]'
A
I am getting the above warning message, I have tried multiple options to escape the ]
but that didn't resolve.
I want to use both the delimiters :\
and print exactly the alphabets A
, B
, C
, D
by printing $1
, $2
, $3
, $4
respectively.
echo 'A:\ B:\ C:\ D:\' | awk -F ':\\\\' -v OFS=- '{print $1,$2,$3,$4,$5}'
givesA- B- C- D-
– glenn jackman Sep 16 '14 at 11:24