【问题标题】:In Bash, why does VAR="*" when echoed it gives out the list of files in that dir?在 Bash 中,为什么 VAR="*" 在回显时会给出该目录中的文件列表?
【发布时间】:2013-11-29 18:10:39
【问题描述】:


我一直致力于在 Bash 脚本中以编程方式设置 cron 作业。
在里面我有这样一行:

JOB="00 12 * * * sh dosomething.sh"

我注意到如果我回显了 var $JOB,它包含目录的文件?

有没有办法将 * 符号作为普通字符存储在 var 中?

谢谢,

【问题讨论】:

    标签: bash crontab


    【解决方案1】:

    你需要引用变量,例如当你回显它时,像这样:

    JOB="00 12 * * * sh dosomething.sh"
    echo "$JOB"
    

    参考:How do I escape the wildcard/asterisk character in bash?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-06
      • 1970-01-01
      • 2022-06-15
      • 2017-05-15
      相关资源
      最近更新 更多