logoalt Hacker News

mmoossyesterday at 4:56 PM1 replyview on HN

I learned, and thought everyone else learned, that the safe characters for POSIX filenames are:

  ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-
That is, the only safe non-alphanumeric characters are dash "-" and underscore "_". Period "." is also considered 'safe' but is tricky for obvious reasons and [IMHO, for the most reliability] best avoided except where necessary.

Authoritative source: POSIX.1-2024 standard, sec. 3.265 Portable Filename Character Set

https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1...


Replies

edoceoyesterday at 5:01 PM

Sometimes, if your file starts with a dash things can be tricky. Don't make any mistakes removing a file named '-fr'