My base.csv file has several entries a sample of which is below.
NAME,IP_ADDRESS,PRI_IP,APP_CODE,APP_NAME,OWNER
test2,10.9.7.12/10.222.101.11,10.9.9.12,545,myapp1,owner1
mytest,10.9.7.12,10.9.9.12,545,myapp1,owner9
checkthis,10.9.7.12/10.222.101.11/10.3.2.111,10.9.9.12,545,myapp1,owner7
Note: the second column is always a single or multiple IP address seperated by delimiter /
I wish to create newbase.csv
with second colum always having only a single ip.
Thus the desired newbase.csv would be like
test2,10.9.7.12,10.9.9.12,545,myapp1,owner1
test2,10.222.101.11,10.9.9.12,545,myapp1,owner1
mytest,10.9.7.12,10.9.9.12,545,myapp1,owner9
checkthis,10.9.7.12,10.9.9.12,545,myapp1,owner7
checkthis,10.222.101.11,10.9.9.12,545,myapp1,owner7
checkthis,10.3.2.111,10.9.9.12,545,myapp1,owner7
Below give me the desired columns that i need but does not split rowns containing multiple ips in the second column into multiple rows.
cat -- base.csv | cut -d, -f2-5 > newbase.csv
Can you please suggest ?