[thinkdba@A-Server ~]$ grep "192.16\." a.txt

192.16.1

192.16.2

192.16.3

1、

[thinkdba@A-Server ~]$ echo $(grep "192.16\." a.txt)

192.16.1 192.16.2 192.16.3

2、

[thinkdba@A-Server ~]$ grep "192.16\." a.txt|tr "\n" " "

192.16.1 192.16.2 192.16.3 [thinkdba@A-Server ~]$

3、

[thinkdba@A-Server ~]$ grep "192.16\." a.txt|sed ':a;N;$!ba; s/\n/ /g'

192.16.1 192.16.2 192.16.3

[thinkdba@A-Server ~]$

4、

[thinkdba@A-Server ~]$ sed -e ':a;$!N; s/\n/ /; ta' a.txt

192.168.1 192.168.2 192.168.3 172.16.3 192.16.1 192.16.2 192.16.3 10.0.4

[thinkdba@A-Server ~]$

5、

[thinkdba@A-Server ~]$ sed -e 's/$/ /' a.txt | xargs

192.168.1 192.168.2 192.168.3 172.16.3 192.16.1 192.16.2 192.16.3 10.0.4

[thinkdba@A-Server ~]$

备忘

Logo

更多推荐