Delete a file from script using wildcards?

I would like to delete, from within a script, a file with name foo-4439.bar, for example, where the number is not known, a priori. I have been trying variations on

run(`rm foo-*`)

but have not managed to come up with anything that works. There is a message about quoting special characters like β€œ*”, but trying that does not help. TIA

You need to use Julia glob rather than shell wildcards

using Glob
for f in glob("foo-*")
     rm(f)
end

or if you’re using v0.6 or later

using Glob
rm.(glob("foo-*"))
2 Likes

Thanks, that does the trick. I had overlooked Glob.jl