Explain Usage Of The Linux Left Bracket /usr/bin/[ Command
Q. I see [ command in /usr/bin directory. What is the /usr/bin/[ command used for?
A.This is test command and it is used to check file types and compare values.
General syntax is as follows:
[ EXPRESSION ]
For example, find out if /etc/passwd exists or not:
[ -f /etc/passwd ] && echo "Yes" || echo "No"
Regularly you write it as follows:
if [ -f /etc/passwd ] then echo "Yes" else echo "No" fi
OR
if test -f /etc/passwd then echo "Yes" else echo "No" fi
Read test or [ command man page for all other expressions.
man [
man test
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Linux / UNIX FAQ:
- What is the difference between UNIX and MAC OS X?
- How do I start Oracle service in UNIX?
- Run crontab Every 10 Minutes
- Difference between Linux and UNIX
- How To AIX UNIX Configure TCP/IP Networking ( NIC )
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Please do not use the comment form to ask for help / question. Ask your question on the excellent Linux tech support forum. Thank you very much for stopping by our site!
Tags: /usr/bin/[, expression, expressions, left bracket, linux command, shell check file types, shell compare values, test command, [ ~ Last updated on: May 5, 2008



Recent Comments
Today ~ 2 Comments
Today ~ 3 Comments
Today ~ 2 Comments
Today ~ 18 Comments
Today ~ 15 Comments