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.

6
  • 2
    In what way is this different from the existing answers? Specifically, herbert's comes to mind. Commented Apr 27, 2017 at 22:40
  • 7
    @Fox His solution uses hardcoded list of characters, which is not an encouraged programming practice because of code readability, compactness and cleanliness. Also some of the special printable ASCII characters could be interpreted by bash, not to mention the most obvious drawback of his one liner - if maximum entropy is desired, can one be sure that all of the available characters are included in the list? And that there are no duplicates which could possibly alter the tr's behaviour? His answer should be replaced by mine since you asked :) Commented Apr 29, 2017 at 13:37
  • 5
    Many if not most web sites have restrictions on the characters that can be in a password, so hard-coding '[:print:]' doesn't feel any better to me than hard-coding the OWASP password special character list. I feel that almost every answer here could be improved by using a variable, but that is such a minor change that I'd only suggest an edit Commented Apr 29, 2017 at 13:54
  • 3
    < /dev/urandom tr -cd '[:graph:]'| tr -d '\\' | head -c 32; echo if you dont want ` characters in generated string. ` because is an escape character in many languages causes problems Commented Mar 8, 2018 at 14:36
  • 2
    @RyanKrage :graph: already excludes space, so a better solution than :print:. Commented Feb 16, 2020 at 10:14