【发布时间】:2019-01-15 21:33:08
【问题描述】:
这是我的文件:
cat abx.txt
select * from table1;
select * from table2;
select * from table3;
yu=$(head -1 abx.txt)
echo $yu
=> 从表中选择 file1.txt file2.txt
分配给变量时如何避免处理*。我已经添加了\*,但变量的值是\*。
【问题讨论】:
这是我的文件:
cat abx.txt
select * from table1;
select * from table2;
select * from table3;
yu=$(head -1 abx.txt)
echo $yu
=> 从表中选择 file1.txt file2.txt
分配给变量时如何避免处理*。我已经添加了\*,但变量的值是\*。
【问题讨论】:
当您回显$yu 时,会发生文件名扩展。您只需用双引号将变量括起来即可:
$ yu=$(head -1 abx.txt)
$ echo "$yu"
select * from table1;
【讨论】: