在 unix 中处理文件时如何忽略 *

How to ignore * when processing a a file in unix

这是我的文件:

cat abx.txt

select * from table1;
select * from table2;
select * from table3;

yu=$(head -1 abx.txt)
echo $yu

=> select file1.txt file2.txt 来自 table

如何在分配给变量时避免处理*。我已经添加了 \* 但变量的值为 \*.

回显 $yu 时文件名正在扩展。您只需要用双引号将变量括起来以防止它:

$ yu=$(head -1 abx.txt)
$ echo "$yu"
select * from table1;