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

后端 未结 2 1820
渐次进展
渐次进展 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:59

    Assuming you mean you don't want to manually open the files:

    sed -i 's/10022012_0630/22052013_1000/' filename*.log
    

    update: since the "-i" switch is not available on AIX, but assuming you have ksh (or a compatible shell):

    mkdir modified
    for file in filename*.log; do
        sed 's/10022012_0630/22052013_1000/' "$file" > modified/"$file"
    done
    

    Now the modified files will be in the modified directory.

提交回复
热议问题