linux - 如何使用 AWK 或 Sed 在 x 个单词后插入换行符\n

标签 linux bash shell unix awk

我把这个放在一行中:

We were born in the earth beyond the land

我希望它在 3 个单词行中,像这样:

We were born
in the earth 
beyond the land

最佳答案

$ xargs -n3 < file
We were born
in the earth
beyond the land

$ egrep -o '\S+\s+\S+\s+\S+' file 
We were born
in the earth
beyond the land

关于linux - 如何使用 AWK 或 Sed 在 x 个单词后插入换行符\n,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15979802/

相关文章:

linux - 自动将所有环境变量从一个 shell 转移到另一个 shell

bash - 设置具有空格mac的环境变量

python - 我如何在python中获取Postgresql中的数据库列表

linux - 应用增量 Linux 补丁

linux - 打开Kafka与外界通信的端口

linux - 从不同的位置运行 bash 脚本但引用脚本所在的位置

python - 从双引号包含的csv文件格式配置单元数据加载

bash - 为字符串运行 ssh 远程命令和 grep

ruby - ruby 和 shell 之间不同的 sudo 环境变量

linux - 如何使用 sar 报告计算 LInux 服务器的内存利用率?