Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Use sed to add comma to end of first field

$
0
0
Example data
Code:

Gi1/10 
Gi1/12          xl32lytscb07
3/11                to nyc
3/12                41764 ecomm
3/13                hxcsxsa 2/1
3/14                ziim570-rsvd
3/15                xl3NDSADM
Po1            VPC trunk to xl3-i
Po2            ***DO NOT ENABLE**
Po13          *** VPC link to
Po101         
Po102          xl3-2lyg1accsgh-fe
Po200         
Po201          09-tietie22834
Po202          16-tietie22834
Po205         
Po206          19-tietie22834
mgmt0          OOB Management
Eth101/1/1    08-tietie2283
Eth101/1/2    08-tietie2283
Eth101/1/3   
Eth101/1/4    08-tietie2283
Eth101/1/5    08-tietie2283
Eth101/1/6   
Eth101/1/7    16-tietie2283
Eth101/1/8    16-tietie2283
Eth101/1/9    16-tietie2283

Desired Result
Code:

Gi1/10, 
Gi1/12,          xl32lytscb07
3/11,                to nyc
3/12,                41764 ecomm
3/13,                hxcsxsa 2/1
3/14,                ziim570-rsvd
3/15,                xl3NDSADM
Po1,            VPC trunk to xl3-i
Po2,          ***DO NOT ENABLE**
Po13,          *** VPC link to
Po101,         
Po102,          xl3-2lyg1accsgh-fe
Po200,         
Po201,          09-tietie22834
Po202,          16-tietie22834
Po205,         
Po206,          19-tietie22834
mgmt0,          OOB Management
Eth101/1/1,    08-tietie2283
Eth101/1/2,    08-tietie2283
Eth101/1/3,   
Eth101/1/4,    08-tietie2283
Eth101/1/5,    08-tietie2283
Eth101/1/6,   
Eth101/1/7,    16-tietie2283
Eth101/1/8,    16-tietie2283
Eth101/1/9,    16-tietie2283

Code that Ive tried

Code:

sed 's/\/[0-9]\/[0-9]*/&,/g' < $x.v >$x.vl

Viewing all articles
Browse latest Browse all 16232

Trending Articles