5

I've been trying to switch to zsh. Something I've missed so far is this:

#!/bin/bash
mv /very/long/path/to/file1.conf{,.old}
#bash expandes that to:
mv /very/long/path/to/file1.conf /very/long/path/to/file1.conf.old

What is that called, and is there a zsh equivalent?

6

It is called Brace Expansion and is present also in zsh.

One important difference between bash and zsh is that in zsh parameter expansion is performed inside braces, but in bash this is not the case.

  • Very strange; it's working for me now. I tried it before and it gave me some error, so I've been avoiding it for a month or so. – Shawn J. Goff Jan 28 '12 at 14:30
  • I also got an error and blamed it on zsh. Turned out I was just putting a space after the comma in the braces. – Dean Dec 6 '12 at 1:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.