I have tried different solution for the problem given on the forum but doesn’t work for the specified Delimiter %$%
, I need to extract one specific column from the file containing 200+ columns.
I tried the following:
awk -F"%$%" '{print $1}' sample.txt > outfile.txt awk 'gsub("%$%",":")' sample.txt > outfile.txt
Advertisement
Answer
The symbol $
is a special character in a regex, so you need to escape it with a , which is also a special character for the string literal, so it needs to be escaped again.
So, finally we have:
$ cat sample ghkjlj;lk%$%23e;k32poek%$%eqdje2oijd%$%xrgtdy5h $ awk -F'%\$%' '{print $1}' sample ghkjlj;lk