echo 'iwant1234cupsoftea.thankyou' | sed -e '/[1-4][1-4]*cupsoftea/s///g'
The first part of the sed command will only edit lines of text that match part of your phrase, in the case where you want to change it in a file.
I'm not sure what your general question is?
Maybe what you want is to remove all digits but the one you want.
Lets say this is a script, and $nc is the number of cups you want.
You could use sed to remove this number from a list of digits, and use that list in the main sed command.
digitlist=$(echo 1234567890 | sed 's/'$nc'//')
echo 'iwant1234cupsoftea.thankyou' | sed 's/['$digitlist']//g'
Last edited by jschiwal; 05-09-2006 at 04:16 AM.