So while i was testing a python program i have been working on i noticed that echo -e "\n"
and printf "\n"
according to the if
statement in bash.
Even though echo -e "\n"
prints two newlines (it appends one by default) and printf only prints one.
if [ "$(echo -e "\n")" == "$(printf "\n")" ]
then
echo 1
fi
and
if [ $(echo -e "\n") -eq $(printf "\n") ]
then
echo 1
fi
both outputs 1 in bash. I have also noticed that assigning the outputs to an variable only outputs a single newline for both echo -e "\n"
and printf "\n"
,
A=$(echo -e "\n")
B=$(printf "\n")
echo $A # outputs a single newline
echo $B # also outputs a single newline
so i am thinking that echo
might output the newline differently with fx. stderr?