gpt4 book ai didi

linux - 如何对以减号开头且包含空格的文件执行 sh 脚本?

转载 作者:太空宇宙 更新时间:2023-11-04 09:02:03 25 4
gpt4 key购买 nike

我正在尝试:

ls | sed 's/.*/"&"/' | xargs sh -- script.sh

对于文件:

  • -test 23.txt
  • test24.txt
  • 测试文本.txt

但在此之后,script.sh 只执行:

-test 23.txt

最佳答案

最好使用 glob :

./script.sh *

无需像您尝试的那样添加双引号

如果你的脚本不遍历参数,试试这个:

for i in *; do ./script.sh "$i"; done

关于linux - 如何对以减号开头且包含空格的文件执行 sh 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19346591/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com