How do I make a folder from a string containing an apostrophe using Ruby? How do I make a folder from a string containing an apostrophe using Ruby? unix unix

How do I make a folder from a string containing an apostrophe using Ruby?


I'd use Dir.mkdir("Gender and Women's Studies").

There's no need to escape anything if you let Ruby do the work. If you need to use the file from the command-line then you'd need to deal with escaping.


Avoid doing that if you can. Although Unix can work with such directories (folder is what Windows calls them), many programs, scripts and utilities are written and tested as if directory (and file) names come without punctuation including spaces, and can become difficult to use.

I manipulate the file-system with such programs and scripts and have learnt that names of [a-zA-Z0-9_], (without the dash '-'), give the least problems.