When I run my script and cat -e output from this script.
What is mean % and $ characters?
cat -e
will print 'unprintable characters' such as new line indicators
$
in this instance indicates the presence of a \n
character which is an EOL
(end of line).
The %
character appears in certain shell environments when you have exited a stream without the presence of a newline character on the end (the effect of your tr -d '\n'
). It isn't technically part of the output, rather an indicator inserted after the output has been rendered to the terminal.
ie, you can strip the $
from the displayed output by piping it back through tr:
$ echo "hello\nhello" | cat -e | tr -d '$'
hello
hello
but you can't strip the % from the displayed output by doing the same thing:
$ echo "hello\nhello" | tr -d '\n' | cat -e | tr -d '%'
hellohello%