LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-07-2008, 09:57 AM   #1
wrapster
Member
 
Registered: May 2008
Posts: 155

Rep: Reputation: 30
a question on all shell commands???


Hi all,
I have a very basic question to ask...
do not mind
How do you figure out if a command is a "built in"(in any shell) or not?

PSlease dont flame me!!!
 
Old 06-07-2008, 10:05 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
"man bash" gives you all the built-ins.

OR

Look for the command in /bin or /sbin. If it's not there, its a built-in
 
Old 06-07-2008, 10:44 AM   #3
crigaeha
LQ Newbie
 
Registered: May 2008
Posts: 3

Rep: Reputation: 0
the type command. binaries need to be in users path.
as in:
type bash
type type
type !

It also tells you if a command is hashed or an alias.

Last edited by crigaeha; 06-07-2008 at 10:47 AM.
 
Old 06-07-2008, 11:19 AM   #4
wrapster
Member
 
Registered: May 2008
Posts: 155

Original Poster
Rep: Reputation: 30
I tried,
type awk
awk is /usr/bin/awk
however a man awk,
gives me its presence even in /usr/xpg4/bin/awk
Similarly there are many commands that are present in 2 or more dirs..
why is it?
Is it dependent on type of operation that is specified on that command?
eg,
Assuming that ls is in /usr/bin and /usr/xpg4/bin
is it that,
when i do ls -l it reads from /usr/bin/
and ls -a reads it from /usr/xpg4/bin

type ls
ls is hashed (/usr/bin/ls)
What does hashed mean?
Also the same was the result when i did a "type touch"
Could i know what these mean?

Thanks

Last edited by wrapster; 06-07-2008 at 11:34 AM.
 
Old 06-07-2008, 03:32 PM   #5
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by wrapster View Post
Similarly there are many commands that are present in 2 or more dirs..
why is it?
Usually to comply with differing standards.
Quote:
Is it dependent on type of operation that is specified on that command?
eg,
Assuming that ls is in /usr/bin and /usr/xpg4/bin
is it that,
when i do ls -l it reads from /usr/bin/
and ls -a reads it from /usr/xpg4/bin
No. The command that will be executed is the first one found in your PATH.
Quote:
type ls
ls is hashed (/usr/bin/ls)
What does hashed mean?
It means the shell has recorded the command location to speed up further execution.

Run the "hash" command to see which commands are remembered.
 
Old 06-07-2008, 04:02 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by wrapster View Post
Assuming that ls is in /usr/bin and /usr/xpg4/bin
is it that,
when i do ls -l it reads from /usr/bin/
and ls -a reads it from /usr/xpg4/bin
...
type ls
ls is hashed (/usr/bin/ls)
What does hashed mean?

Are you on openSolaris or something?
 
  


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
a question on all shell commands??? wrapster Solaris / OpenSolaris 2 06-07-2008 11:44 AM
more shell commands mf5160 Linux - Software 3 03-14-2007 01:41 PM
Alias or shell script to confirm 'exit' commands from a shell rose_bud4201 Programming 2 03-08-2006 02:34 PM
commands in shell? kalleanka Linux - General 9 02-01-2006 07:38 AM
shell commands! krishlinux General 1 10-05-2003 04:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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