要将shell字符串赋值给变量,可以使用以下方式:
str='Hello, World!'
echo $str
str=`echo Hello, World!`
echo $str
str=$(echo Hello, World!)
echo $str
无论使用哪种方式,都可以将字符串赋值给变量,然后使用变量进行后续的操作。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: centos中如何创建及运行shell脚本