# Delete a file from script using wildcards?

**URL:** <https://discourse.julialang.org/t/delete-a-file-from-script-using-wildcards/7022>\
**Category:** General Usage\
**Created:** [November 12, 2017, 9:58am UTC](https://discourse.julialang.org/t/delete-a-file-from-script-using-wildcards/7022 "2017-11-12T09:58:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Post date:** [November 12, 2017, 9:58am UTC](https://discourse.julialang.org/t/delete-a-file-from-script-using-wildcards/7022/1 "2017-11-12T09:58:12Z")

</div>

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

```julia
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

---

<div class="post-metadata">

**Author:** ![Simon\_Bolland](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simon_bolland/32/8920_2.png) [@Simon\_Bolland](https://discourse.julialang.org/u/Simon_Bolland)\
**Post date:** [November 12, 2017, 10:17am UTC](https://discourse.julialang.org/t/delete-a-file-from-script-using-wildcards/7022/2 "2017-11-12T10:17:45Z")

</div>

You need to use Julia glob rather than shell wildcards

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

```

or if you’re using v0.6 or later

```julia
using Glob
rm.(glob("foo-*"))

```

---

<div class="post-metadata">

**Author:** ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Post date:** [November 12, 2017, 10:46am UTC](https://discourse.julialang.org/t/delete-a-file-from-script-using-wildcards/7022/3 "2017-11-12T10:46:08Z")

</div>

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