Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 1
    Note that you also add a newline at the end. To fix that, and optimize by replacing fold -w 10 | head -n 1 with head -c10 Commented Apr 7, 2021 at 7:17
  • 1
    I've been using this for years however in macOS Big Sur it breaks with "Input error" Commented Apr 23, 2021 at 0:19
  • 1
    add LC_ALL as suggested in another answer: cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n 1 Commented Aug 18, 2023 at 8:19