Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用linux shell命令将多行输出合并为一行,重新格式化报告文件_Linux_Sed_Awk_Format - Fatal编程技术网

使用linux shell命令将多行输出合并为一行,重新格式化报告文件

使用linux shell命令将多行输出合并为一行,重新格式化报告文件,linux,sed,awk,format,Linux,Sed,Awk,Format,我有一个包含以下输入的文件: name: ted position:11.11.11.11" applicationKey:88 channel:45 protocol:4 total:350 name:janet position:170.198.80.209 applicationKey:256 channel:44 protocol:4 total:1 我喜欢外面看起来像这样 tedd 11.11.11.11 88 45 4 350 janet 170.198.80.209 256

我有一个包含以下输入的文件:

name: ted 
position:11.11.11.11"
applicationKey:88
channel:45
protocol:4
total:350

name:janet
position:170.198.80.209
applicationKey:256
channel:44
protocol:4
total:1
我喜欢外面看起来像这样

tedd  11.11.11.11 88 45 4 350
janet 170.198.80.209 256 44 4 1
有人能帮忙吗?

这应该可以:

awk -F':' '{printf "%s %s",$2,ORS=NF?"":"\n"}END{print "\n"}' file
$ cat file
name:ted
position:11.11.11.11
applicationKey:88
channel:45
protocol:4
total:350

name:janet
position:170.198.80.209
applicationKey:256
channel:44
protocol:4
total:1
$ awk -F':' '{printf "%s %s",$2,ORS=NF?"":"\n"}END{print "\n"}' file
ted 11.11.11.11 88 45 4 350 
janet 170.198.80.209 256 44 4 1