Skip to content
Advertisement

Prevent * to be expanded in the bash script

Linux bash script:

JavaScript

Execution results:

JavaScript

* is expanded to the list of files, which is actually script itself. How can I prevent this and see actual variable value? In general case, var can be more complicated than *, for example: home/alex/mydir/*.

Advertisement

Answer

you need to escape your variables, too:

JavaScript

And in your function:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement