AWK split string then deliminate it as well -


need splitting below.

100gb@sdb,100gb@sdc 

into this

sdb sdc 

everything i've tried keeps giving me

sdb 100gb 

for arbitrary number of disks, try:

$ echo '100gb@sdb,100gb@sdc,10kb@sdd' | awk -f'[@,]' '{for (i=2;i<=nf;i+=2) printf "%s ",$i; print ""}' sdb sdc sdd  

answers original question

using awk

$ echo '100gb@sdb,100gb@sdc' | awk -f'[@,]' '{print $2,$4}' sdb sdc 

using sed

$ echo '100gb@sdb,100gb@sdc' | sed 's/^[^@]*@//; s/,[^@]*@/ /' sdb sdc 

using bash

$ s='100gb@sdb,100gb@sdc'; s=${s#*@}; echo ${s/,*@/ } sdb sdc 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

python 3.x - PyQt5 - Signal : pyqtSignal no method connect -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)