#!/bin/bash read_from_pipe() { read "$@" <&0; } echo "$(read_from_pipe | head -1)"