Change string char at index X

前端 未结 3 1252
名媛妹妹
名媛妹妹 2020-12-16 12:26

I\'m searched for a long time how to do a simple string manipulation in UNIX

I have this string:

theStr=\'...............\'
3条回答
  •  温柔的废话
    2020-12-16 13:00

    I don't know if it's elegant, or which version of bash you need, but

    theStr="${theStr:0:4}A${theStr:5}"
    

    The first part returns first four characters, then the character 'A', and then all the characters starting with the 6th one

提交回复
热议问题