Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Nov 2000 11:35:20 -0500
From:      "Andresen,Jason R." <jandrese@mitre.org>
To:        Tommy Forrest - KE4PYM <tforrest@mcs.net>
Cc:        "freebsd-questions@FreeBSD.ORG" <freebsd-questions@FreeBSD.ORG>
Subject:   Re: What is "["?
Message-ID:  <3A101848.D9F7105E@mitre.org>
References:  <200011130004.SAA06022@mailbox.mcs.net>

next in thread | previous in thread | raw e-mail | index | archive | help


Tommy Forrest - KE4PYM wrote:
> 
> Rooting around (no pun intended) my 4.0 system today I happened upon
> a file called "[" in /bin.  Not knowing what this file was I deleted
> it.
> 
> Rule number one:  Dont delete that in which you do not know.  Rename
> it.
> 
> Lesson learned.  Soon after my network died.  I rebooted the system.
> Lots of bad things (tm) happened.  Nothing would start up.  So I
> logged in and did a man [ and found it was a test utility.  Then I
> did a locate test |more  Found /bin/test.  Copied test to [ and
> rebooted.  Everything is happy.
> 
> What, exactly, is "[".  Why is it on my system as "["?

It's the test command, just like the manpage said.  It's called "[" so
people writing shell scripts can do something like
if [ -e file ] 
do
	good stuff
done

instead of 
if test -e file
do
	good stuff
done

It makes shell scripting a little more readable.  BTW, don't copy test
to "["
hard link it instead.  Both files are the same, and when test is
updated, you want
"[" to be updated as well.  Besides, right now you have a redundant copy
of test
sitting on your system eating disk space (in root).


-- 
   _  _    _  ___  ____  ___   ______________________________________
  / \/ \  | ||_ _||  _ \|___| | Jason Andresen -- jandrese@mitre.org
 / /\/\ \ | | | | | |/ /|_|_  | Views expressed may not reflect those 
/_/    \_\|_| |_| |_|\_\|___| | of the Mitre Corporation.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A101848.D9F7105E>