I have the following terminal command, which matches volumes called A001R45R, A123R45R, etc.

diskutil eraseVolume HFS+ FreshMag /Volumes/*R45R

But I also want it to match volumes called B001R4G5, B150R4G5, etc. How can I use the OR expression in the wildcard? I tried the following, but it doesn't work:

$ diskutil eraseVolume HFS+ FreshMag /Volumes/{*R45R,*R4G5}
The third parameter does not appear to be "bootable" or "nonbootable"
$ diskutil eraseVolume HFS+ FreshMag /Volumes/"{*R45R,*R4G5}"
Unable to find disk for /Volumes/{*R45R,*R4G5}

I'm using bash.

  • Do You have other volumes which contains R4 in the middle of their name? If not You can use: diskutil eraseVolume HFS+ FreshMag /Volumes/*R4* Commented Feb 9, 2015 at 19:41
  • Your shell is doing the expansion here - you should clarify which shell you're using.
    – Alex
    Commented Feb 9, 2015 at 21:03
  • Mateusz, that won't work for me. These were just two examples, but I have others that don't share characters. I'm using bash.
    – Elliott
    Commented Feb 9, 2015 at 23:27

1 Answer 1


I figured out the answer myself. Apparently the bash version in OS X supports square brackets, but not curly brackets. Weird. It's bash 3.2.53. This command works:

diskutil eraseVolume HFS+ FreshMag /Volumes/*[R45R,R4G5]

However, in this particular case, it's actually better to use a more specific command like this:

diskutil eraseVolume HFS+ FreshMag /Volumes/[A-Z][0-9][0-9][0-9][R,L]???

It should be noted that if more than one volume matches this wildcard, the command will fail, because the wildcard expands to both filenames.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .