one nice thing to use in combination with cut is rev, which allows to get fields indexed from the back, even if the count of separators varies:
cut
rev
echo "one-two-three" | rev | cut -f 1 -d "-" | rev
echo "one-two-three-four" | rev | cut -f 1 -d "-" | rev
one nice thing to use in combination with
cutisrev, which allows to get fields indexed from the back, even if the count of separators varies:echo "one-two-three" | rev | cut -f 1 -d "-" | revecho "one-two-three-four" | rev | cut -f 1 -d "-" | rev