3
用顺序索引替换字符串
有人可以建议一种优雅的方式来实现这一目标吗? 输入: test instant () test instant () ... test instant () //total 1000 lines 输出应为: test instant1 () test instant2 () test instant1000() 空行在我的输入文件中,并且同一目录下有很多文件需要立即处理。 我试图用它替换同一个目录中的许多文件,但没有用。 for file in ./*; do perl -i -000pe 's/instance$& . ++$n/ge' "$file"; done 错误: Substitution replacement not terminated at -e line 1. Substitution replacement …