I used stat on two different versions of Ubuntu and it printed different types of quotes.

14.04 (coreutils 8.21-1ubuntu5.1):

$ stat --format %N test.txt

16.04 (coreutils 8.25-2ubuntu2):

$ stat --format %N test.txt

Why does stat use this uncommon quoting style in the older version and is there a way to tell stat which type of quotes it should use?


I know that in version 8.26 quoting style was introduced for stat (https://savannah.gnu.org/forum/forum.php?forum_id=8745):

  stat --format=%N for quoting file names now honors the
  same QUOTING_STYLE environment variable values as ls.

But prior to this change there should be a consistent behavior between the versions or were there other changes I'm not aware of?

  • 1
    What locale are you on?
    – muru
    Jun 7, 2017 at 6:26
  • @muru en_US.UTF-8 on both
    – Sethos II
    Jun 7, 2017 at 6:38

1 Answer 1


From the GNU stat documentation:

The ‘%N’ format can be set with the environment variable QUOTING_STYLE. If that environment variable is not set, the default value is ‘shell-escape’. Valid quoting styles are:

Output strings as-is; this is the same as the -N or --literal option.


Like ‘shell’, but also quoting non-printable characters using the POSIX proposed ‘$''’ syntax suitable for most shells.


Quote strings as for C character string literals, except use surrounding quotation marks appropriate for the locale, and quote 'like this' instead of "like this" in the default C locale. This looks nicer on many displays.

stat didn't use this variable in 8.21 (the change was made last November). The output from 14.04 looks like it used QUOTING_STYLE=locale. Presumably that was the (implicit) default then.

  • But the question is still why it's different in 8.21 and 8.25. From what I know quoting style for stat was introduced in 8.26. See edit.
    – Sethos II
    Jun 7, 2017 at 7:16
  • @SethosII customization of quoting style was introduced in 8.26, but quoting was already being used (using gnulib's quoting functions). It's entirely possible something changed in gnulib while nothing changed in coreutils and the output changed.
    – muru
    Jun 7, 2017 at 7:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .