I have seen many methods for removing some characters based on regular string or special match using tr etc. But I didn't find any way to delete a character based on accurate index in a string.
For example: In var="hello world"
,I want to delete the 5th char 'o' and then var should be like "hell world"
. The code should apply to all other normal strings. Thanks in advance.
CodePudding user response:
One method is:
n=5
var="hello world"
var=${var:0:n-1}${var:n}