If I type echo hello
, my terminal looks like this:
My-Computer:~ user$ echo hello
hello
My-Computer:~ user$
But if I have a function like this
stringen () { cat /dev/urandom | env LC_CTYPE=C tr -cd 'a-Z-A-z-0-9' | head -c "$1" ; }
It looks like this
My-Computer:~ user$ stringen 18
^\k6JPWVIUdEiudcWSMy-Computer:~ user$
See that it doesn't print it in a new line? Same thing when using printf
vs echo
. How can I do so that my functions makes new lines like this? I thought that the ;
would take care of this but obviously not.
For example, this returns what I want
variable=$(stringen 18)
echo $variable
Is it something with echo?