Translate

Archives

Difference between [ and [[ in Shell Scripts

Many shell script writers are aware that [ is a synonym for the test command (See the test(1) man page) but few are fully aware of the actual differences between [ and [[. The test command implements the portable syntax specified by the IEEE Std 1003.1-2008 (POSIX) standard. In most shells (older Bourne shells being the main exception), [ is a synonym for test (but requires a final argument of ]) and is a shell builtin. In addition, there is usually an external executable of that name, e.g. /bin/[ or /usr/bin/[. The IEEE 1003.1-2008 standard (POSIX) defines a mandatory feature