only allow numbers regex code example Example: regex all not numbers echo 1a2b3c | sed 's/[^0-9]//g' #Replaces all not numbers abc