泰山神 发表于 2018-8-27 06:17:30

shell脚本中大括号的扩展在变量中的问题

  root@ubuntu:/tmp/test# touch /tmp/test/{2,3}
  root@ubuntu:/tmp/test# ls
  23
  root@ubuntu:/tmp/test# rm /tmp/test/{2,3}
  root@ubuntu:/tmp/test# ls
  root@ubuntu:/tmp/test# t={2,3}
  root@ubuntu:/tmp/test# touch /tmp/test/$t
  root@ubuntu:/tmp/test# ls
  {2,3}
  解决办法:
  root@ubuntu:/tmp/test# eval touch /tmp/test/$t
  root@ubuntu:/tmp/test# ls
  23

页: [1]
查看完整版本: shell脚本中大括号的扩展在变量中的问题