error function bash

using sed

function error {
  [ $( sed 's/\s/+/g' <<<${PIPESTATUS[*]} | bc ) -eq 0 ] && return || echo error && exit 1
}

using awk

function error {
  [ $( awk 'BEGIN{ OFS="+"} $1=$1; { print }' <<<${PIPESTATUS[*]} | bc ) -eq 0 ] && return || echo error && exit 1
}

append text to standard input on linux

apeend a new line to stdin using cat

printf %s\\n ID-{1..3}' '{1..9..4} | cat <(echo c1 c2) -

join a text to stdin using bash

echo 1 2 3 | echo nums: $(</dev/stdin)

join a text to stdin using awk

awk '{ print "nums:", $0 }' <<< '1 2 3'

join a header text to stdin using awk

echo -e "a\nb\nc" | awk 'BEGIN{print "num"} {print $0}'

filter content on file maintaining the first line “header”

grep mail /etc/passwd | cat <(head -1 /etc/passwd) -