Strange file '/usr/bin/['

I noticed a strange file in /usr/bin


-rwxr-xr-x  1 root root       39704 Sep 29 08:33 *

What is that?

It is a pity that you only post the output and not the command you used to get it. Thus we have to guess. I assume you used something like the -F option:

henk@boven:/usr/bin> ls -lF 
-rwxr-xr-x 1 root root 39704 17 mrt  2014 *
henk@boven:/usr/bin>

where the * means that it is an executable

henk@boven:/usr/bin> ls -l 
-rwxr-xr-x 1 root root 39704 17 mrt  2014 
henk@boven:/usr/bin>

shows the file name more clealy:
As this is in /usr/bin. there is a good change that you get more information using

man 

Please look for yourself :wink:

And please, when applicable, copy/paste not only thh output, but prompt, comand, output and next prompt when posting computer text. It is only a little bit more moving with the mouse and it delivers so much more information on what user you are, what working directory you are in, what you did, etc.

Sorry. I noticed when issuing ‘l /usr/bin’ command.

'man ’ gives me:


TEST(1)                                                               User Commands                                                              TEST(1)






NAME
       test - check file types and compare values


SYNOPSIS
       test EXPRESSION
       test


        EXPRESSION ]
        ]
        OPTION


DESCRIPTION
       Exit with the status determined by EXPRESSION.
...

I am not sure if I understand correctly. Does this mean that **** is related to test?

Yes, it is the same.

The originators of Unix created the test command. Some of them found out that you could write neater scripts using . And when you then implemented that ] as an argument to just was understood as the last argument (without doing something) you could then write lines like

 -z $STRING ] 

instead of

test -z $STRING

As these test statements were (and are) of course numerous in most shell scripts, they were in most shells implemented as an internal statement, still upwards compatibel with the old test command. Thus when you use the commands as given above in bash, the internal is executed, which avoids starting a seperate process for the test/ program.

Of course the original implementation caried over a few strange things from that upwards compatibilty from the past. It is therefore that ksh implemented a new internal construct using … ]]. That is also implemented in bash. Personaly I prefer this last one.

BTW, I remember from times ago that and test were links (logical imho). But now:

henk@boven:/usr/bin> ls -l  test
-rwxr-xr-x 1 root root 39704 17 mrt  2014 
-rwxr-xr-x 1 root root 35616 17 mrt  2014 test
henk@boven:/usr/bin>

they seem to be different files with different sizes. ???

Thanks for explaining!

I guess this means they are not the same in some sense.

Yes, of course.

Well I guess we should not bother as in general the shell buildin ones will be used. :wink:

BTW, I always see this as a nice example to show to people that think you can not have these type of characters in a file name. This exists already for more then 40 years.

Nice mini-tutorial, Henk. I think some of the more inquisitive Linux newcomers will appreciate the info.:slight_smile:

I don’t name my files with or ] in the name. But I suppose it would not be a problem (e.g. in a script) if one is aware of that. Maybe putting filenames in quotes will avoid any problems?

I do not know if I understnd you here correctly, but what I mean is that most of the non alphbetic, non numeric characters (including white space characters) can be used in file names (/ being the most important exception). However some of these characters have a special meaning to the shell.

metacharacter
A character that, when unquoted, separates words. One of the following:

| & ; ( ) < > space tab

And there are more like $ introducing parameter expansion.
Thus when you want to address these file name through the CLI (or script) you must take precautions like quoting. The is not amongst those and you can see that I used it in post #2 without any quoting.

But it is not a bad idea to always quote file names with “strange characters”. Just to be sure.

As additional information, take into account that Linux nowadays uses UTF-8 encoded Unicode also for file names by default. That means that thousands of characters can be used.

henk@boven:~/test/unicode> l
totaal 8
drwxr-xr-x  2 henk wij 4096 11 jan 09:59 ./
drwxr-xr-x 16 henk wij 4096 11 jan 09:54 ../
-rw-r--r--  1 henk wij    0 11 jan 09:54 hello
-rw-r--r--  1 henk wij    0 11 jan 09:59 أهلا
-rw-r--r--  1 henk wij    0 11 jan 09:58 Χαίρετε
-rw-r--r--  1 henk wij    0 11 jan 09:58 Здравствуйте
-rw-r--r--  1 henk wij    0 11 jan 09:54 नमस्ते
henk@boven:~/test/unicode>

(some of the above filenames may show open squares or ? in black rhomboids, meaning that you do not have the fonts installed to render them).

Learn dutch, @Fraser_Bell :smiley: and search for “Korte uitleg” in the forums. It might even be that they wouldn’t suffer too much from Translate.

Thanks for explaining.

That’s what I meant too.