Echo displays strange output when '?' is used

In bash or sh terminal I get this strange response when using echo.

It's really best just to give you the code:

user@localhost:~$ text="?"; echo $text
P T V
user@localhost:~$ text='?'; echo $text
P T V
user@localhost:~$ text='?'; printf "$text\n"
?

So, printf works nicely but is there a way to get printf to take the escape sequences of variables?

I think it might have happened after messing around with Gnome-Shell extensions but not sure.

Any idea why it's happening or how to get rid of it?

I bet you have a P , a T , and a V file in your working directory, as ? is a "special pattern character" that "matches any single character" (cf man bash ).

3 Likes

I do, yes. I have all those directories.

At least I know where it's coming from now. Thanks.

1 Like