how to display text on TWRP recovery screen using a sh file?
This piece of code is extracted from the ZIP package of SuperSU. It's working correctly on all devices I've ever had (displaying text to the TWRP terminal)

OUTFD=1
readlink /proc/$$/fd/$OUTFD 2&gt;/dev/null | grep /tmp &gt;/dev/null
if [ "$?" -eq "0" ]; then
  # rerouted to log file, we don't want our ui_print commands going there
  OUTFD=0

  # we are probably running in embedded mode, see if we can find the right fd
  # we know the fd is a pipe and that the parent updater may have been started as
  # 'update-binary 3 fd zipfile'
  for FD in `ls /proc/$$/fd`; do
    readlink /proc/$$/fd/$FD 2&gt;/dev/null | grep pipe &gt;/dev/null
    if [ "$?" -eq "0" ]; then
      ps | grep " 3 $FD " | grep -v grep &gt;/dev/null
      if [ "$?" -eq "0" ]; then
        OUTFD=$FD
        break
      fi
    fi
  done
fi

ui_print_always() {
  echo -n -e "ui_print $1\n" &gt;&gt; /proc/self/fd/$OUTFD
  echo -n -e "ui_print\n" &gt;&gt; /proc/self/fd/$OUTFD
}


To display message, use ui_print_always "some message" instead of echo.