单线posix命令以bash中的小写字符串
问题
我有这个com:
sed $((SS - default_scripts))!d customScripts.txt
它给了我foo bar
。
我想将其转换为小写。
尝试尝试
当我尝试使用|的尝试时 awk'{print tolower($ 0)}'
命令什么也没返回:
$($(sed $((SS - default_scripts))!d customScripts.txt) | awk '{print tolower($0)}')
最终
请在我的错字上启发我,或向我推荐另一种以紧凑的方式将整个字符串转换为小写的方法。谢谢你!
Problem
I have this comand:
sed $((SS - default_scripts))!d customScripts.txt
and it gives me Foo Bar
.
I want to convert this to lowercase.
Attempt
When I tried using the | awk '{print tolower($0)}'
command on it it returned nothing:
$($(sed $((SS - default_scripts))!d customScripts.txt) | awk '{print tolower($0)}')
Final
Please enlighten me on my typo, or recommend me another POSIX way of converting a whole string to lowercase in a compact manner. Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的错别字将所有内容包装在
$(...)
中,因此首先尝试执行sed
part的输出,然后尝试执行sed ... |尴尬... 管道。
当您使用尴尬时,您不需要SED命令或Shell算术操作。如果我理解您要使用此操作:
正确地是这个尴尬命令:
Your typo was wrapping everything in
$(...)
and so first trying to execute the output of just thesed
part and then trying to execute the output of thesed ... | awk ...
pipeline.You don't need sed commands nor shell arithmetic operations when you're using awk. If I understand what you're trying to do with this:
correctly then it'd be just this awk command:
尴尬的管道应与
sed
替换在同一命令中,以便处理sed
的输出。您不需要围绕他们俩的其他命令替换。
The pipe to awk should be inside the same command substitution as
sed
, so that it processes the output ofsed
.You don't need another command substitution around both of them.