在 Linux 中,您可以使用 echo
命令来输出变量的值
variable_name="Hello, World!"
echo $variable_name
这将输出 “Hello, World!”。
variable_name="Hello, World!"
echo "The value of the variable is: $variable_name"
这将输出 “The value of the variable is: Hello, World!”。
variable_name="Hello, World!"
echo 'The value of the variable is: $variable_name'
这将输出 “The value of the variable is: $variable_name”,因为单引号不会展开变量。
printf
命令:variable_name="Hello, World!"
printf "The value of the variable is: %s\n" "$variable_name"
这将输出 “The value of the variable is: Hello, World!”。printf
命令允许您使用格式字符串来控制输出的格式。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:linux怎么引用变量值