linux - Convert list of FQDN and IPs to two column CSV -


i'd take list this:

example.com 1.2.3.4 ftp.example.com 2.3.4.5 3.4.5.6 www.example.com 4.5.6.7 5.6.7.8 6.7.8.9 

and parse comma delimited csv format when opened in popular spreadsheet program, parent fqdns in column , children ips in column b.

i'd using native linux binaries can bake existing bash script.

any welcome, , in advance.

this might work (gnu sed):

sed -r '/[[:alpha:]]/h;//d;g;s/(.*)\n(.*)/\2,\1/' file 

if line contains alphabetic characters i.e. address, store in hold space , delete it. otherwise, append address current line , swap 2 fields replacing newline , , print.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -