Translate

Archives

Image of Advanced Programming in the UNIX Environment, Second Edition (Addison-Wesley Professional Computing Series)
Image of Modern Operating Systems (3rd Edition)
Image of RHCE Red Hat Certified Engineer Linux Study Guide (Exam RH302) (Certification Press)
Image of XSLT 2.0 and XPath 2.0 Programmer's Reference (Programmer to Programmer)

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