LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-23-2010, 06:33 AM   #1
hattori.hanzo
Member
 
Registered: Aug 2006
Posts: 167

Rep: Reputation: 15
Concatenate the output to comma delimited


I would like to create csv output from an ipcalc calculation.

Code:
[me@host scripts]$ ./ipcalc 192.168.30.40/255.255.255.248
Address:   192.168.30.40        11000000.10101000.00011110.00101 000
Netmask:   255.255.255.248 = 29 11111111.11111111.11111111.11111 000
Wildcard:  0.0.0.7              00000000.00000000.00000000.00000 111
=>
Network:   192.168.30.40/29     11000000.10101000.00011110.00101 000
HostMin:   192.168.30.41        11000000.10101000.00011110.00101 001
HostMax:   192.168.30.46        11000000.10101000.00011110.00101 110
Broadcast: 192.168.30.47        11000000.10101000.00011110.00101 111
Hosts/Net: 6                     Class C, Private Internet
I am using the following to get the data that I need but cannot figure out how to concatenate the output to comma delimited.

Code:
[me@host scripts]$ ./ipcalc 192.168.30.40/255.255.255.248 | awk '{ print $2}' | sed -n '5,7p'
192.168.30.40/29
192.168.30.41
192.168.30.46
Thanks & Regards

Update:

Figured it out :-)

Quote:
[me@host scripts]$ ./ipcalc 192.168.30.40/255.255.255.248 | awk '{ print $2}' | sed -n '5,7p' | tr '\n' ','
192.168.30.40/29,192.168.30.41,192.168.30.46

Last edited by hattori.hanzo; 11-23-2010 at 06:56 AM.
 
Old 11-23-2010, 07:13 AM   #2
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,503

Rep: Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893
I am pretty sure you could have done it all with your awk command. I am not familiar with ipcalc but if you give me the generated output I can show you how?
ie, output of
Code:
./ipcalc 192.168.30.40/255.255.255.248
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
output pid's from ps to a comma delimited file machielr Linux - General 11 04-08-2010 03:33 AM
column re-alignment - space delimited to comma delimited hattori.hanzo Linux - Newbie 9 03-05-2009 12:54 AM
separating a comma delimited line mrobertson Programming 7 07-27-2005 01:56 PM
Comma-Delimited Website Filenames Apocalypse General 1 11-09-2003 09:05 AM
comma delimited file cdragon Programming 5 06-21-2002 07:55 PM


All times are GMT -5. The time now is 08:56 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration