4 x fibre cards elimination

Hi,

I have variables like mentioned below and want to separate as mentioned in output.

var1="4 x fibre cards"
var2="2 fibre cards"
var3="6 - fibre cards"
var4="4 x dual-port"

I have variables like this.I want to separate numbers from this and fibre cards from this.

output has to be
4 fibre-cards
2 fibre-cards
6 fibre-cards
4 dual-port

Any one can help please...it would be great if any one can provide reply asap as it is very urgent.

None over there to solve this??

What about you?
Here is the kickstart:

var1=$(awk 'NF==3{printf "%s %s-%s",$1,$2,$3}NF==4{printf "%s %s-%s",$1,$3,$4}' <<< $var1)

Hi,

try:

for i in ${!var*}; do sed "s/ [x-] / /g;s/ \(.*\) / \1-/" <<< "${!i}"; done

The output looks like this (on bash):

4 fibre-cards
2 fibre-cards
6 fibre-cards
4 dual-port

The script will search for all variables named var* and then do two simple
substitutions, delete occurances of " x" or " -" and join two separate
words by a hyphen. You should be able to modify this according to your
needs.

HTH Chris

Thanks chirs..!!
Great...