LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-03-2011, 08:15 AM   #1
tgrzelak
LQ Newbie
 
Registered: Nov 2009
Posts: 3

Rep: Reputation: 0
What is the program /usr/bin/[


I have found this program on my RHEL 5.5 machines? What is its purpose?

-rwxr-xr-x 1 root root 32296 Jan 10 13:27 [

Thanks!
 
Old 02-03-2011, 08:18 AM   #2
Sayan Acharjee
Member
 
Registered: Feb 2010
Location: Chennai, India
Distribution: Manjaro
Posts: 624

Rep: Reputation: 64
Quote:
Originally Posted by tgrzelak View Post
I have found this program on my RHEL 5.5 machines? What is its purpose?

-rwxr-xr-x 1 root root 32296 Jan 10 13:27 [

Thanks!
This is test command and it is used to check file types and compare values. e.g.,

Code:
[ -f /etc/passwd ] && echo "Yes" || echo "No"
It checks if /etc/passwd exists or not.

Read the man page to know more,

Code:
#man [
or
Code:
#man test

Last edited by Sayan Acharjee; 02-03-2011 at 08:19 AM.
 
Old 02-03-2011, 08:18 AM   #3
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
I have no such file on my 5.5. I'd assume someone created it with a typo.

Try to view the file, if it's binary, run strings on it and see if you can tell what it is.

edit...

Nope, I stand corrected. I do have the file.

Last edited by crabboy; 02-03-2011 at 08:22 AM.
 
Old 02-03-2011, 09:03 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Actually [ is both a shell built-in and a command. The same as echo. Usually built-ins have precedence over commands. You can verify this using
Code:
type [
whereas if you want to find all the available versions:
Code:
type -a [
and to find all the related stuff (e.g. man pages):
Code:
whereis [
the [ command is provided by the coreutils package. If you check the man page, as suggested above, you will see the [ command has the following synopsis:
Code:
[ EXPRESSION ]
where the last argument is a (mandatory) closing square bracket.
 
Old 02-03-2011, 09:48 AM   #5
tgrzelak
LQ Newbie
 
Registered: Nov 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks!

I don't have a man page on it. But as everyone has stated, I am more comfortable now seeing that this is a legitimate program. I was worried it was a hack or an artifact of a bad line command.

Thanks!
 
Old 02-03-2011, 11:22 AM   #6
lumak
Member
 
Registered: Aug 2008
Location: Phoenix
Distribution: Arch
Posts: 799
Blog Entries: 32

Rep: Reputation: 111Reputation: 111
BTW, the programs test and [ don't support "==" so if you want your bash scripts to be POSIX compatible, use "=" instead.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a program for /usr/bin for scanning with color using scanimage? frenchn00b Programming 12 08-02-2010 03:27 PM
echo $PATH = /home/g3rc4n/bin:/usr/local/bin:/usr/bin:/bin:/usr/games ? i_heart_pandas Linux - Software 7 09-18-2009 08:33 AM
Failed to chck remot comnd executin using shells /usr/bin/ssh and /usr/bin/rsh farnaw4u Linux - Software 2 04-06-2009 12:08 AM
path in services wrong for clamav updated frm 0.75 to 0.80 usr/bin vs usr/local/bin Emmanuel_uk Linux - Newbie 3 04-22-2005 01:02 AM
Can't move program files to /usr/local/bin/ asburyguy Linux - Newbie 4 04-03-2004 11:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration