both operations are implemented using awk
contents of indexOf file:
echo "$1" "$2" | awk '{print index($1,$2)}'
eg.
indexOf 'abcdeabcdabcaa' 'ca' 12
contents of indexOfAfter file:
echo "$1" "$2" "$3" | \ awk '{s=substr($2,$1);posn=index(s,$3);if (posn>0) print $1+posn-1; else print 0;}'
source share