Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That is clever. What is the {1..5} syntax called? I am trying to figure out what the zsh equivalent is.



Relevant terms are "brace expansion" and "range". And, um, at least for me, the command I wrote works verbatim in zsh. (I think zsh is supposed to be bash-compatible like that.) Brace expansion works like this (in zsh and bash):

  % echo {1..5}
  1 2 3 4 5
  % echo meh{1..5}
  meh1 meh2 meh3 meh4 meh5
  % echo {1..5}{1..5}
  11 12 13 14 15 21 22 23 24 25 31 32 33 34 35 41 42 43 44 45 51 52 53 54 55
  % echo {1,2,4}{1,3,9}
  11 13 19 21 23 29 41 43 49
I have observed one difference in brace expansion: {a..f} -> "a b c d e f" in bash, but "{a..f}" in zsh. Curious. Oh well.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: