Why is a filename surrounded by double quotes with single quotes around a character when displayed in terminal?

Why would a file show up surrounded by double quotes with a character surrounded by single quotes within it?


I am using Ubuntu Server 22.04.3 LTS. A service desk management program (Atlassian Jira Data Center 9.12.4 if that is relevant) installed on the server writes to various log files. Some of the files are rotated, and after an update some of the log files display as shown above when I execute

~$ ls /var/[application-directory-path]/log

Other log files display without any quotes. Some examples:


There are many posts about single and double quotes in Unix systems, especially with the GNU developers adding single quotes around files with spaces. I am somewhat familiar with the nuance surrounding these characters and Unix, but this is new to me, and I can’t find an explanation anywhere online (likely because it is difficult to phrase the problem).

I looked at the logging configuration files and nothing appears different between the delinquent insight_automation.log rotate settings and the other log files.
My only guess is that the dot in the name is a different Unicode character that is escaped similar to the way spaces in file names are. Maybe One Dot Leader, Interpunct, or Bullet?

I am sure I can fix the issue simply, but knowing why it is displayed like this would help a lot.

Asked By: Logan Kitchen


(I’ll just answer this here so you don’t need to read all the whining about that feature in the linked answer.)

Recent versions of GNU ls by default wrap filenames with special characters in quotes, when printing to a terminal, for the purpose of making the output unambiguous, and e.g. making any trailing spaces visible. In most cases, they use single quotes, but if the name itself contains single quotes, they might use double-quotes to wrap the whole name.

Assuming you’re using one of those versions of ls (which is likely if your system isn’t old), then your filename is insight_automation.log'.'2024-03-13, and ls prints it quoted as "insight_automation.log'.'2024-03-13".

The output should be suitable as input to the shell (well, to Bash anyway), so you can check with e.g.

ls "insight_automation.log'.'2024-03-13"

which, if it works, should find your file.

Or, if you want ls to print the filename without any extras, run

ls -N

instead. Or ls -N *'* or such to match just filenames that have single quotes in them.

As to why you’d have a filename with quotes, we can’t know without seeing the rest of your system.

Answered By: ilkkachu