Possible Duplicate:
Extracting a regex matched with 'sed' without printing the surrounding characters
How do I make this only print test:
echo "atestb" | sed -n 's/\(test\)/\1/p'
Possible Duplicate:
Extracting a regex matched with 'sed' without printing the surrounding characters
How do I make this only print test:
echo "atestb" | sed -n 's/\(test\)/\1/p'
You need to match the whole line:
echo "atestb" | sed -n 's/.*\(test\).*/\1/p'
or
echo "atestb" | sed 's/.*\(test\).*/\1/'