Linux – sed + how to remove the last string after specific character

kshlinuxsedsolaris

how to remove the last string after "." character include the "." character itself

implementation can be with sed under Linux/Solaris operation system

example of IP address before change

      192.9.200.1     ( need to remove the .1 )

expected results

      192.9.200

other example

      100.2.2.101FFF

expected results

      100.2.2

Best Answer

maybe with cut instead of sed?

echo "10.10.10.5" | cut -d. -f-3

if it has to be sed

echo "10.10.10.5fsdfdsf" | sed -e 's/\.[^\.]*$//'