# What is /bin/[



## Kiiski (Aug 23, 2009)

I noticed there is file /bin/[.
Anybody know what is this file?
Because of location, if I understand correctly it is part of base system.
Why it is named so "funny"?

System:
>uname -r
7.2-RELEASE-p1
> uname -m
i386


----------



## jrick (Aug 23, 2009)

test(1)


----------



## graudeejs (Aug 23, 2009)

test(1)


----------



## Carpetsmoker (Aug 23, 2009)

[(1)

When you run a script, i.e.:

```
if [ "hello" == "${world}" ]; then
   echo "Hello world"
fi
```

Then `[' is just a command. It is the same as the _test_ command (Actually, they are hard links, use ls -i on them and they have the same inode) so you can also write:

```
if test 'hello' == ${world} ]; then
```

But [ is better because it is easier to read.


----------



## vermaden (Aug 23, 2009)

You can also simplify it like that:

```
[ "hello" == "${world}" ] && echo "Hello world" || echo "FAIL"
```


----------



## vivek (Aug 23, 2009)

Common sys admin example:

```
[ -f /etc/resolv.conf ] && do_something || die "File not found"
```


----------



## Alt (Aug 23, 2009)

haha when i sysadmin something i do this command every mourning lol


----------

