Q:

How to use sed to extract a string

I need to extract a number from the output of a command: cmd.  The output is type: 1000
So my question is how to execute the command, store its output in a variable and extract 1000 in a shell script.  Also how do you store the extracted string in a variable? 

A:

If the output is rigidly restricted to "type: " followed by a number, you can just use cut. 
var=$(echo 'type: 1000' | cut -f 2 -d ' ')

Obviously you'll have to pipe the output of your command to cut, I'm using echo as a demo. 
In addition, I'd use grep and then cut if the string you are searching is more complex.  If we assume there can be all kind of numbers in the text, but only one occurrence of "type: " followed by a number, you can use the command:
>> var=$(echo "hello 12 type: 1000 foo 1001" | grep -oE "type: [0-9]+" | cut -f 2 -d ' ')
>> echo $var
1000

