I construct my own locatedb using frcode so it would contain filesizes after paths (it helps me look for large files quickly). I store the path separated from the size by a tab character. I've noticed that if I use locate in the command-line, I get a ? (question mark) where the tab should be, unless I pipe it to cat, which is weird. Does anybody know why this is?

$ mkdir test-locatedb && cd test-locatedb
$ touch a b c d e f g
$ du -a | awk -v 'OFS=\t' '{print $2,$1}' | /path/to/frcode > test.locatedb
$ locate --database=test.locatedb a
$ locate --database=test.locatedb a | cat
./a     1
./test.locatedb 1    
$ /usr/lib/locate/frcode -v
frcode (GNU findutils) 4.4.2

1 Answer 1


I suspected that this is coded into locate by checking if output is stdout or not. And indeed, locate has a condition to replace non-printable characters with question marks when output is a tty (see printquoted.c and qmark.c). It considers whitespace in the ASCII control character range to be non-printable as well. I think this is unfortunate, as one would not expect output to the terminal to change when piping through cat. This is true for findutils 4.6.0 as well. I submitted a bug report.

You must log in to answer this question.

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