I need to take the sum of a field which is tilde (~) delimited. Problem I have is that my data is also having delimiter escaped.
Example
1~CEO~ashok\~kumar~1000
As we see in 3rd field above we have escaped delimitter which I want to avoid. I'm running the below command which doesn't handle this.
$ cat test.out|awk -F'~' 'BEGIN {sum=0} {sum+=$4} END{print sum}'
Assume the test.out data as:
1~CEO~ashok\~kumar~1000
2~CFO~Ranjan~2000
3~CEO~kumar~1000
So my output should be 4000. But currently with my command I get only 3000!