bash - How to echo "some text" and result of function in one line? - Ask Ubuntu
i'm starting learn bash scripting. , had question. code below working fine,
echo "here current directory: " pwd but if want have result of pwd written in same line explanation string? how it? thanks.
you can use command substitution
echo "here current directory: $(pwd)" however might want habit of preferring printf on echo
printf 'here current directory: %s\n' "$(pwd)" note: tell echo not include terminating newline e.g.
echo -n "here current directory: " pwd but it's not recommended - see why printf better echo?
Comments
Post a Comment