
$ variable="This is the first line \
>This is the second line"
上面的代码中,变量“variable”的值就是两行文本。
另外,也可以使用“<<” *** 作符来实现多行赋值,例如:
$ variable=<<EOF
>This is the first line
>This is the second line
>EOF
上面的代码中,变量“variable”的值就是两行文本。
总之,在 Linux 中有多种方法可以实现多行赋值,可以根据实际情况选择最合适的方法。
把这些命令存到一个文件 (假设文件名为 codefile) 中,然后在文件的第一行插入一行#!/bin
然后把文件改为可执行的,在命令行里面执行
./codefile
即可。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)