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