shell中使用sed替换指定位置的字符

来源:互联网 发布:西门子苏州研究院数据 编辑:程序博客网 时间:2024/05/16 10:37

#!/bin/sh

read str

read index

read replace

index = `expr $index - 1`

echo $str |  sed 's/\([a-zA-Z0-9]\{'$index'\}\)\(.\)\(.*\)/\1'$replace'\3/'

原创粉丝点击