如何在bash中将每一行的首字母大写? [英] How to capitalize first letter of each line in bash?
本文介绍了如何在bash中将每一行的首字母大写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一个将bash中每一行的首字母大写的命令.
I'm looking for a command that capitalizes the first letter of each line in bash.
实际上我使用了以下命令:
Actually I used this command:
sed 's/^\(.\)/\U\1/'
但是我需要使用另一个命令而不是"\ U".
But I need to use another command instead of "\U". .
推荐答案
为什么需要使用除\U
之外的其他内容?
Why do you need to use something else than \U
?
您可以使用\u
,该字母只能大写一个字母:
You can use \u
which only capitalizes one letter:
sed 's/./\u&/'
或者,使用参数扩展:
while read line ; do echo "${line^}" ; done
这篇关于如何在bash中将每一行的首字母大写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文