Q:

how do I use sed to delete lines with single digit instead of double

I have this line.
sed -i '/Total number 1/d' /tmp/test.txt

This will delete lines,
Total number 1

but it also deletes,
Total number 11

Total number 12

Total number 13

how do I set it to delete single digit only?

A:

Add a dollar sign to the end sed -i '/Total number 1$/d' /tmp/test.txt
Also, if you want to delete any single digit, replace 1: sed -i '/Total number [0-9]$/d' /tmp/test.txt
Finally, if the number isn't necessarily at the end of the line, you could also have the pattern end when either the end of line or a non-digit is found: sed -i -E '/Total number [0-9]($|[^0-9])/d' /tmp/test.txt

