Change string char at index X

前端 未结 3 1258
名媛妹妹
名媛妹妹 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:15

    You can achieve this with sed, the stream line editor:

    echo $theStr | sed s/./A/5

    First you pipe the output of $theStr to sed, which replaces the fifth character with A.

提交回复
热议问题