LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-16-2007, 06:07 PM   #1
slackamp
Member
 
Registered: Dec 2005
Distribution: slackware-current
Posts: 86

Rep: Reputation: 16
misterious bin file.


i just recently found this file

# ls -l /bin/[
-rwxr-xr-x 1 root root 24376 2006-06-24 21:59 /bin/[*

# file /bin/[
/bin/[: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), stripped


# ldd /bin/[
linux-gate.so.1 => (0xb7fc9000)
libc.so.6 => /lib/tls/libc.so.6 (0xb7e7c000)
/lib/ld-linux.so.2 (0xb7fca000)


anyone know what this is?
 
Old 06-16-2007, 06:13 PM   #2
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
Yes, it is the "[" command of course.
Serious! It is used in scripts mostly.

Eric
 
Old 06-16-2007, 06:19 PM   #3
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
It's a test like 'if'.

[[ a == b ]] && 'some command'
is pretty much the same as
if [[ a == b ]]; then 'some command'
 
Old 06-16-2007, 06:21 PM   #4
slackamp
Member
 
Registered: Dec 2005
Distribution: slackware-current
Posts: 86

Original Poster
Rep: Reputation: 16
lol really???? i would think that would be a part of bash and not a seperate binary file like the command `cd`. which package is it under?

found the package where it belongs. coreutils. wow you learn new things everyday.

Last edited by slackamp; 06-16-2007 at 06:23 PM.
 
Old 06-16-2007, 06:48 PM   #5
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Quote:
Originally Posted by slackamp
lol really???? i would think that would be a part of bash and not a seperate binary file like the command `cd`.
Actually, it is a builtin, but is also available as an external. And '[' and '[[' are distinct - the first is a synonym for the older 'test' command and the second is a reserved word which doesn't do word splitting and pathname expansion 'on the words between the [[ and ]]', which can screw you up with the '[' builtin if you don't quote carefully.
 
Old 06-16-2007, 10:42 PM   #6
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
lol, this is the second time someone has asked this. Yeah, it definitely looks suspicious ... but it's just like 'test', and part of bash.
 
Old 06-17-2007, 05:10 AM   #7
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,299
Blog Entries: 61

Rep: Reputation: Disabled
Just try:
$ [ --help
 
Old 06-17-2007, 08:56 AM   #8
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
But follow that by doing this:
/usr/bin/[ --help
and you'll get a different output.
On systems the '[' is a link to 'test'.
Most scripting relies on the internal capabilites of the shell to process conditons -which can include a whole range of functions which are also available as external programs: [, [[, test, true, false and also the handling of 'if' statements which is the same thing(0,1) and don't forget about && and ||.
Different shells handle (or not) these things their own way.
When you see code like this:
if [[ something else...
it's really like three ifs or three tests. But there is usually a reason for doing it one way or another -either with test, single bracket or double bracket. For instance this 'or' doesn't work with double brackets
using BASH.
This:
[ "test1" = "not" -o "test2" = "so" ]
this:
if test "test1" = "not" -o "test2" = "so" ; then
and this:
[[ "test1" = "not" ]] || [[ "test2" = "so" ]] &&
all will do mostly the same thing depending on what's being tested.
 
Old 06-17-2007, 09:41 AM   #9
Randux
Senior Member
 
Registered: Feb 2006
Location: Siberia
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705

Rep: Reputation: 55
Cool

Quote:
Originally Posted by H_TeXMeX_H
lol, this is the second time someone has asked this. Yeah, it definitely looks suspicious ... but it's just like 'test', and part of bash.
It's been a lot more than twice! Anybody who looks into what's on his system (especially Slackers) will notice it and start wondering I remember thinking "who rooted my system " the day I saw it.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Installing .bin-files, leave the file in /usr/local/bin/ ? lagu2653 Linux - Software 1 11-08-2005 08:30 PM
Misterious 3rd FF window mattp Linux - Software 18 10-17-2005 03:28 PM
/tools/bin/env: /tools/bin/bash: No such file or directory DaZjorz Linux From Scratch 21 07-27-2005 07:11 AM
bin/bash:usr/bin/lpr NO SUCH FILE OR DIRECTORY Adibe_Hamm Linux - Newbie 3 10-14-2003 02:30 AM
misterious traffic while smbmount saavik Linux - Networking 3 02-12-2003 12:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 11:46 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