Editing/Replacing content in multiple files in Unix AIX without opening it

后端 未结 2 1802
渐次进展
渐次进展 2020-12-04 01:19

I have multiple files in Unix directory. files names are as below.
EnvName.Fullbkp.schema_121212_1212_Part1.expd EnvName.Fullbkp.schema_121212_1212_Part2.expd

2条回答
  •  自闭症患者
    2020-12-04 01:42

    It's some kind of extreme optimist who suggests sed -i on AIX.

    It's a bit more likely that perl will be installed.

    perl -pi -e 's/10022012_0630/22052013_1000/' EnvName.Fullbkp.schema_121212_1212_Part*.expd
    

    If no perl, then you'll just have to do it like a Real Man:

    for i in EnvName.Fullbkp.schema_121212_1212_Part*.expd
    do
      ed -s "$i" <<'__EOF'
    1,$s/10022012_0630/22052013_1000/g
    wq
    __EOF
    done
    

    Have some backups ready before trying these.

提交回复
热议问题