0
I am new to Bash scripting, I've used Visual Basic in Windows before and am looking for a bash equivalent string function for VB's inStr()
.
example in VB :
strMain = "abcABC123ABCabc"
searchStartPos = 6 'Start searching at 6th char.
subStr = "AB" 'Look for "AB".
pos = inStr(searchStartPos, strMain, subStr)
print pos
10 'A match is found at 10th char.
I would really appreciate if someone could tell me how to do this in Bash.
I created a solution for you. Depending on what you want to do next, there may be better solutions. E.g. if you want to replace or delete the substring, you don't need to know its position explicitly. Compare XY problem. Now when the question is answered please do not change its scope. If you tell me (in a comment) what you want to do next, I may be able to guide you further.
– Kamil Maciorowski – 2019-11-28T08:19:47.720