I have a command "awk -F'[~|^]' 'BEGIN{RS=FS}/*searching string*/{print NR-1}' <<< *user defined string*
", which will provide me the delimiters count based on the given search string.
However the user defined string is not having any pre-defined delimiters. I got this command from this link of stackoverflow "Using multiple delimiters in awk"
But the above code is working only if the delimiters are in single character. When I am using "^|" as a delimiter it is not considering 2 characters as a single delimiter.
Please find a sample as per my above statement,
Input : a=name^|phone^|contact^|title^|address^|mobilenumber (delimiter may vary)
Searching String : title
Command : awk -F'[~|^]' 'BEGIN{RS=FS}/title/{print NR-1}' <<< $a
Output: 3
So could anyone please help me how i will fit all the delimiters (like - "~", "|", "^", "^|") in the above mentioned command.