Bash file is as
#!/bin/bash
SomeErrorHandler () {
(( errcount += $? ))
echo -e $errcount
}
trap SomeErrorHandler ERR
uname +a 2>/dev/null
uname +a 2>/dev/null
uname +a 2>/dev/null
uname +a 2>/dev/null
uname +a 2>/dev/null
uname -a 1>/dev/null
declare -a f
# this is never printed
f="$(SomeErrorHandler)"
echo -e "$f" | awk 'END {print}'
I want the returning value be from the value of a
as
1
2
3
4
5
to return the last match which is 5
instead the output just echos everything in a
.
I also tried with sed
but output is same. It seems that this is just one record