Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I have seen both in Cygwin and in Linux the [ command under /bin. Whenever I run it I get an error saying: missing ].

I never understood what this command does, I just one day found it wanted to find out what it does (and whether it is useful or not)

NOTE: I would have checked the man entry, for an answer, but sadly, there is no entry in it for [

share|improve this question

marked as duplicate by JdeBP, Tog, Kevin Panko, Shekhar, Mark Mar 17 '14 at 19:44

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

What is the command? – zekk Mar 14 '14 at 23:18
@TiagoƇ. The command is called [ – inixsoftware Mar 14 '14 at 23:18
In bash, it is re-implemented as a built-in command. At a bash prompt type help [ – glenn jackman Mar 15 '14 at 0:13
up vote 6 down vote accepted

This is test command.

For example, find out if /etc/passwd exists or not:

[ -f /etc/passwd ] && echo "Yes" || echo "No"

Regularly you write it as follows:

if test -f /etc/passwd
  echo "Yes"
  echo "No"
share|improve this answer

Have you ever seen/noticed if conditions in shell scripts? They are of the form:
[ -e $FILE ]

In those cases, the condition checking functionality is usually built-into the shell interpreting those scripts, usually bash or sh-aliased-bash.

The binaries that you see serve the same purpose, but are present so condition checks can be used in shells without such functionality built-in.

share|improve this answer

The [ square bracket is another way to call the test command.

Refer to test's Man page for further info :)

share|improve this answer

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