【问题标题】:How to ignore * when processing a a file in unix在unix中处理文件时如何忽略*
【发布时间】: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

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

【问题讨论】:

    标签: shell unix glob


    【解决方案1】:

    当您回显$yu 时,会发生文件名扩展。您只需用双引号将变量括起来即可:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-05
      • 2018-09-03
      • 2011-02-07
      • 2021-12-19
      • 2021-11-28
      • 1970-01-01
      相关资源
      最近更新 更多