Input : a=ABCD~BCDA~BABD~CACD~CICD~DEFG Searching String : BABD Output: 2 As per the above input i have a string with delimiter '~'. Here, I want to get the delimiter position according to any of the search string from the input string. Could anyone please help me out from it.
In case of unknown delimiters, how could i manage? Is a code can check multiple delimiters at a single go?
I have tried with the below code but not able to find the delimiter's position. echo $a |awk -v s="BABD" '{print index($1,s)}' Output: 11 instead of 2
awk -F "~" 'BEGIN{RS=FS}/BABD/{print NR-1}' <<< 'ABCD~BCDA~BABD~CACD~CICD~DEFG'
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)