在shell中应用ex 执行脚本。
for file in $*
do
ex - $file < exscript
done
$cat exscript
s/thier/their/g
s/writeable/writables/g
wq
2.也可以是here document的方式<<
for file in $*
do
ex - $file << end_of_end
s/thier/their/g
s/writeable/writables/g
wq
end_of_end
done
一般我们都是用EOF作为标示的。
3.g/^KP/,/^KE/j
%!sort, j是ex中的合并命令。!是执行shell命令的。!后跟shell命令。
g/^KP/,/^KE/-1s/$/@@/
g/^KP/,/^KE/j
%!sort
%s/@@/^M/g
完成KP到KE的排序,并仍就是原来的模式。