如何将下面每个字母的第一个字母从大写转换为小写?
例如SentMessage
将成为sentMessage
和NotAttemptedCreditLimitReached
将成为notAttemptedCreditLimitReached
......等
下面的单词列表。它们只是在一个文本文件中。
SentMessage
DeliverySucceeded
DeliveryFailed
DeliveryTimedOut
NotAttemptedCreditLimitReached
NotAttemptedChargingFailure
SubscriptionFailed
SentReportSMDeliveryStatus
FailedToSendReportSMDeliveryStatus
ReportSMSucceeded
ReportSMFailed
最初正在考虑使用 notepadd++,但对其他建议 bash/python ... 等持开放态度
$ cat testw
SentMessage
DeliverySucceeded
DeliveryFailed
DeliveryTimedOut
NotAttemptedCreditLimitReached
NotAttemptedChargingFailure
SubscriptionFailed
SentReportSMDeliveryStatus
FailedToSendReportSMDeliveryStatus
ReportSMSucceeded
ReportSMFailed
$ sed -i 's/[A-Z]/\L&/' testw
$ cat testw
sentMessage
deliverySucceeded
deliveryFailed
deliveryTimedOut
notAttemptedCreditLimitReached
notAttemptedChargingFailure
subscriptionFailed
sentReportSMDeliveryStatus
failedToSendReportSMDeliveryStatus
reportSMSucceeded
reportSMFailed
如果你有 gnu sed 然后使用:
sed -i 's/[A-Z]/\L&/' file
[A-Z]
将匹配第一个大写字母&
是按模式对匹配字符串的反向引用(在本例中为单个大写字母)\L
将给定的反向引用转换为小写本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句