Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我希望能够在我拥有的具有不同数字的文本块中1替换为。1.
1
1.
那么,如何找出要在替换中使用的匹配数字?
这是一个例子:
echo "1 MORE TEXT HERE" | sed 's/[0-9]/[0-9]\./g'
我想[0-9]在第二部分sed给我比赛。
[0-9]
sed
echo "1 MORE TEXT HERE" | sed 's/[0-9]/&\./g'
&是完全匹配
&
使用的解决方案gnu awk
gnu awk
echo "1 MORE TEXT HERE" | awk '{print gensub(/[[:digit:]]*/,"&.","")}' 1. MORE TEXT HERE