LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 05-28-2016, 04:40 AM   #1
badbetty
Member
 
Registered: Jan 2014
Posts: 135

Rep: Reputation: Disabled
an executable noticed in /bin name '['


hello, I am unsure if an executable found in /bin is legit or not. I'd appreciate some comments or ways to safely check what it is if it is unusual.

The executable is in /bin and is named '['.

I installed Slackware 14.1 64 bit and added a few other programs from SlackBuilds website a few weeks ago, but only noticed this morning.

I have moved the executable elsewhere out of the way for now.

Thank you.
 
Old 05-28-2016, 04:53 AM   #2
GazL
LQ Guru
 
Registered: May 2008
Posts: 5,193
Blog Entries: 18

Rep: Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914
Put it back. It's a synonym for 'test'.

Ever seen:
Code:
if [ -f file ]; then
  # do something
fi
That's the '[' executable right there.
 
Old 05-28-2016, 05:04 AM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2019 CentOS6.10 CentOS7.7 + 50+ other Linux OS, for test only.
Posts: 17,274

Rep: Reputation: 3570Reputation: 3570Reputation: 3570Reputation: 3570Reputation: 3570Reputation: 3570Reputation: 3570Reputation: 3570Reputation: 3570Reputation: 3570Reputation: 3570
The command /bin/[ : Is from the package coreutils : coreutils-8.21-x86_64-1.txz
ftp://ftp.slackware.org.uk/slackware...slackware64/a/

Please tryout the [command] --help : $ /bin/[ --help
Code:
$ /bin/[ --help
Usage: test EXPRESSION
  or:  test
  or:  [ EXPRESSION ]
  or:  [ ]
  or:  [ OPTION
Exit with the status determined by EXPRESSION.

      --help     display this help and exit
      --version  output version information and exit
.
.
.
.

-

Last edited by knudfl; 05-28-2016 at 05:06 AM.
 
1 members found this post helpful.
Old 05-28-2016, 06:51 AM   #4
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-14.2.1.2 on Lenovo Thinkpad W520
Posts: 9,013

Rep: Reputation: Disabled
To know more see the specification: http://pubs.opengroup.org/onlinepubs...ties/test.html

This page also provide further explanations, see "Application usage" and "Examples".

Last edited by Didier Spaier; 05-28-2016 at 06:54 AM.
 
1 members found this post helpful.
Old 05-28-2016, 08:01 AM   #5
badbetty
Member
 
Registered: Jan 2014
Posts: 135

Original Poster
Rep: Reputation: Disabled
[solved]an executable noticed in /bin name '['

I can't understand why I had paranoia going on ;-) Lack of some knowledge [even basic] obviously.

Thank you all for the replies.
 
Old 05-28-2016, 12:11 PM   #6
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,897

Rep: Reputation: 578Reputation: 578Reputation: 578Reputation: 578Reputation: 578Reputation: 578
'[' is not exactly equal to test, nor to the shell builtin '['.
 
1 members found this post helpful.
Old 05-29-2016, 04:02 AM   #7
GazL
LQ Guru
 
Registered: May 2008
Posts: 5,193
Blog Entries: 18

Rep: Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914
So, how do test and '[' differ?
 
Old 05-29-2016, 02:54 PM   #8
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,897

Rep: Reputation: 578Reputation: 578Reputation: 578Reputation: 578Reputation: 578Reputation: 578
Code:
bash-4.1$ type test
test is a shell builtin
bash-4.1$ type [
[ is a shell builtin
'help test' and 'help [' will show the help for the builtins

'/bin/test' and '/bin/[' are separate progs, although some distros may alias [ to test

The specific differences will depend on which versions of shell and coreutils are in question. I've seen very few cases where the 'real' /bin/test is explicitly called and I've never seen /bin/[ called directly.
 
Old 05-29-2016, 03:04 PM   #9
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 1,588

Rep: Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224
That's interesting that it's an actual executable. I always assumed it was just part of the shell syntax.
 
Old 05-29-2016, 03:46 PM   #10
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 4,299

Rep: Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959
"[[" is a shell keyword. "[" is an actual command, and used to be needed so that it could be used by rudimentary startup or recovery shells that lacked the builtin equivalent. These days, when systems boot with an initramfs far larger than those old machines had installed memory, it's pretty much a leftover relic.

And BTW, the difference between "test" and "[" is that the latter requires a final argument of "]", whereas "test" would barf on that.
 
5 members found this post helpful.
  


Reply

Tags
coreutils


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] Synergy: executable not found when it is in /usr/bin heronlin Slackware 8 06-12-2012 01:55 PM
Executable won't run in /usr/bin m_yates Linux - Newbie 3 12-14-2011 09:18 AM
[SOLVED] How to make a bin file an executable? MWH Linux - Software 6 03-14-2010 10:11 AM
Executable removed from /usr/bin on restart. Rob001 Linux - Newbie 2 10-15-2009 08:11 AM
suse 9.2 - /usr/bin/[ Executable - what is this? nathanv117 SUSE / openSUSE 3 01-23-2005 09:20 AM

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

All times are GMT -5. The time now is 08:51 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration