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.
如何在linux的文件中使用制表符更改三个或更多连续空格的所有实例?
阻止stackoverflow吃空白。假设您想用单个 x 替换 3 个 a。
示例数据:
echo "123aa456aaaaaa789aa0aa" > foofile
使用 sed 和正则表达式:
sed -r 's/aaa+/x/g' foofile
输出
123aa456x789aa0aa