Using a perl oneliner
echo "hell-hello-helloo" | perl -F/-/ -ane 'print join("-",@F[0,1]);'
Or if you don't like the -F
option to automate splitting, either of the below two:
echo "hell-hello-helloo" | perl -e 'print join "-", (split /-/, <>)[0,1]'
echo "hell-hello-helloo" | perl -pe '$_ = join "-", (split /-/)[0,1]'