我想将每行的第一个字母转换为小写,直到文件的末尾.如何使用
shell脚本执行此操作?
我试过这个:
plat=`echo $plat |cut -c1 |tr [:upper:] [:lower:]``echo $plat |cut -c2-`
但这只会将第一个字符转换为小写字母.
我的文件看起来像这样:
Apple Orange Grape
预期结果:
apple orange grape
解决方法
你可以用sed做到这一点:
sed -e 's/./\L&/' Shell.txt
(可能比较安全
sed -e 's/^./\L&\E/' Shell.txt
如果你想扩展它.)