在Bash中使用一个周期更换空间 [英] Replace a Space with a Period in Bash
本文介绍了在Bash中使用一个周期更换空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只需要能够做的是更换一个空格(
)以点(。
)的在bash的字符串。
我认为这将是pretty简单,但我新,所以我无法弄清楚如何修改这个用一个类似的例子。
All I need to be able to do is replace a space () with a dot (
.
) in a string in bash.
I think this would be pretty simple, but I'm new so I can't figure out how to modify a similar example for this use.
推荐答案
使用内联外壳的字符串替换。例如:
Use inline shell string replacement. Example:
foo=" "
# replace first blank only
bar=${foo/ /.}
# replace all blanks
bar=${foo// /.}
请参阅http://tldp.org/LDP/abs/html/string-manipulation.html了解更多详情。
这篇关于在Bash中使用一个周期更换空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文