Environment
- bash
Problems
When I defined shell values such below, how is space chars or tab chars in variable processed?
packages='
httpd
postgresql
redis
'
yum install ${packages}
How to solve
It is expanded to yum httpd postgresql redis
, and it works as expected.
Description
Let's see how it is expanded with using echo
command.
#!/bin/bash
# your code goes here
packages='
httpd
postgresql
redis
'
echo ${packages}
echo '${packages}'
echo "${packages}"
output
httpd postgresql redis
${packages}
httpd
postgresql
redis
When I quote variable with double quote, it expand, but tab characters or space characters does not replaced with single space.
Top comments (0)