Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

The name of the file is '[' . When I open it up in vi it looks like it's a copy of 'test'. It's owned by root.

share|improve this question
    
What's the output of stat /bin/[? –  SirCharlo Aug 23 '12 at 20:02
    
@SirCharlo File: `/usr/bin/[' Size: 30244 Blocks: 64 IO Block: 4096 regular file Device: 805h/2053d Inode: 2499684 Links: 1 Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2012-08-23 14:50:24.545242581 -0400 Modify: 2011-02-23 08:22:21.000000000 -0500 Change: 2012-07-09 22:31:52.133720601 -0400 –  Josh Aug 23 '12 at 20:08

2 Answers 2

up vote 7 down vote accepted

That file is supposed to be there (or under /usr/bin/[). It allows you to type, for instance, [ -f $HOME/.bashrc ] && echo ".bashrc exists", which is equivalent to test -f $HOME/.bashrc && echo ".bashrc exists".

Reality is a bit more complicated, since bash overrides /usr/bin/[ with its own [, so you can use the [ executable by providing a full path, /usr/bin/[ -f $HOME/.bashrc ] && echo ".bashrc exists".

share|improve this answer
    
I'm curious now. I don't have that file.. –  SirCharlo Aug 23 '12 at 20:07
1  
Try /usr/bin/[. –  pablomme Aug 23 '12 at 20:10
    
@pablomme Thanks! –  Josh Aug 23 '12 at 20:21
    
@pablomme You're the man! –  SirCharlo Aug 23 '12 at 20:28

It is a version of test that requires a ] as last argument. It's often used in shell scripts, like in

if [ -e some_file ]; then ...

(but in most modern shell, like Bash, it's a builtin command).

It's required by POSIX

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.