Hello "${world}"
"Hello ${world}"
in bash script should behave the same, but which one of them is a better practise?
Something like "${base_dir}"/"${filename}"
looks ugly, right?
Hello "${world}"
"Hello ${world}"
in bash script should behave the same, but which one of them is a better practise?
Something like "${base_dir}"/"${filename}"
looks ugly, right?
The command echo Hello "${world}"
takes two arguments: "Hello" and whatever string the variable world
is set to. It outputs them with a single space between them.
You have more control over the output by giving echo
a single string argument. For example, if you want a tab instead of a space, you can enter a tab character between the words of the passed string: echo "Hello<tab>${world}"
whereas you'd get a space if you give them as separate arguments.
The command echo "${base_dir}"/"${filename}"
takes a single argument, because there are no space separators. There is no reason not to use echo "${base_dir}/${filename}"
.