Run command

I need to run:

run(zip code.zip "*.jl")

But * does not work. Help please.

1 Like

Julia’s Cmd objects don’t spawn a shell, which is why that doesn’t work.

You can directly spawn a shell via something like run(`bash -c ls *`) if you want, but that depends on a particular shell being present on your system, and isn’t a good idea if you interpolate variables into the command since that could lead to injection attacks. But it can be convenient for quick REPL work.

For a more robust solution, see https://github.com/vtjnash/Glob.jl.

edit: or readdir, walkdir, and the other commands in the Filesystem section of the docs.

2 Likes

I found another solution. Using “InfoZIP” package and filtering jl files using “filter” function.

But I wanted to understand why my code does not work. Thanks!!