Awk 如何并排打印输出?

Awk 如何并排打印输出?,awk,Awk,我从脚本中获得以下输出: 192.168.0.10 192.168.0.10 undefined 192.168.0.130 192.168.0.130 ansible 192.168.0.141 192.168.0.141 undefined 192.168.0.252 192.168.0.252 undefined 但我希望它是这样的: 192.168.0.10 192.168.0.10 undefined 192.168.0.130 192.168.0.130 ansible 192.

我从脚本中获得以下输出:

192.168.0.10
192.168.0.10
undefined
192.168.0.130
192.168.0.130
ansible
192.168.0.141
192.168.0.141
undefined
192.168.0.252
192.168.0.252
undefined

但我希望它是这样的:

192.168.0.10 192.168.0.10 undefined
192.168.0.130 192.168.0.130 ansible
192.168.0.141 192.168.0.141 undefined
192.168.0.252 192.168.0.252 undefined
我见过如何使两行相邻,但我在3行失败^^

awk '{getline b;printf("%s %s\n",$0,b)}'
尝试使用粘贴

paste - - - < file.txt
粘贴--
仅使用空格分隔符

paste -d ' ' - - - < file.txt
paste-d'--
使用
awk
您可以尝试以下内容吗

awk '{count++;printf("%s%s",$0,count%3==0?ORS:OFS)} END{if(count%3!=0){print ""}}' Input_file
解释:添加上述代码的详细解释

awk '                                       ##Starting awk program from here.
{
  count++                                   ##Increasing variable count value with 1 here.
  printf("%s%s",$0,count%3==0?ORS:OFS)      ##Printing current line and either new line(ORS) or space(OFS) based opon condition if count is divided by 3 or NOT.
}
END{                                        ##Starting END block for this awk code here.
  if(count%3!=0){                           ##Checking condition if count is NOT fully divided by 3 then do following.
    print ""                                ##Printing null variable here in case previous line was not having new line so to add it in last.
  }
}
'  Input_file                               ##Mentioning Input_file name here.

pr更适合这种情况:
pr-3ats''ip.txt