Bash glob parameter only shows first file instead of all files

后端 未结 4 777
遇见更好的自我
遇见更好的自我 2020-12-12 08:36

I want to run this cmd line script

$ script.sh   lib/* ../test_git_thing

I want it to process all the files in the /lib folder.

<         


        
4条回答
  •  悲哀的现实
    2020-12-12 09:04

    The argument list is being expanded at the command line when you invoke "script.sh lib/*" your script is being called with all the files in lib/ as args. Since you only reference $1 in your script, it's only printing the first file. You need to escape the wildcard on the command line so it's passed to your script to perform the globbing.

提交回复
热议问题