 |
 |
tcsh built-in "where"
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
tcsh had the built-in command "where," which would return all the paths for a specified binary on your system. You would be presented with a list paths, the top one being the one that would be executed first (first in your $PATH). This was a handy little tool.
bash, however, only has "which," which returns the path of the binary specified that first appears in your $PATH. Is there any way to get some "where" functionality in bash?
Thanks. 
|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
| |
|
|
|
 |
|
 |
|
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status:
Offline
|
|
can't you just type /bin/tcsh to enter the tcsh shell, and then type your where command, or is that not suited to your needs? it works for me, but i don't know how you are wanting this to work.
|
|
"Have sharp knives. Be creative. Cook to music" ~ maxelson
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
Originally posted by philzilla:
can't you just type /bin/tcsh to enter the tcsh shell, and then type your where command, or is that not suited to your needs? it works for me, but i don't know how you are wanting this to work.
I totally could do that... but I totally never would. I guess it's something that I wish bash could do natively, that's all. 
|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
| |
|
|
|
 |
|
 |
|
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status:
Offline
|
|
Originally posted by [APi]TheMan:
I totally could do that... but I totally never would.
son... you're on your own

|
|
"Have sharp knives. Be creative. Cook to music" ~ maxelson
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
You're ok in my book, phil.

|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
| |
|
|
|
 |
|
 |
|
Junior Member
Join Date: May 2004
Status:
Offline
|
|
here paste this into a file called where.
then type "chmod 755 where" in terminal
put the file somewhere in your path.
i use ~/bin for all my personal scripts and tools.
Code:
#!/bin/tcsh
if ($#argv > 0) then
foreach arg ($argv)
where $arg
end
else
echo "where: Too few arguments."
endif
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 2000
Location: Caracas, Bolivarian Republic Of Venezuela
Status:
Offline
|
|
Originally posted by [APi]TheMan:
tcsh had the built-in command "where," which would return all the paths for a specified binary on your system. You would be presented with a list paths, the top one being the one that would be executed first (first in your $PATH). This was a handy little tool.
bash, however, only has "which," which returns the path of the binary specified that first appears in your $PATH. Is there any way to get some "where" functionality in bash?
Thanks.
try 'type -a'
hth
|
Contra a barbárie, o estudo; Contra o individualismo, a solidariedade!
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
Originally posted by leira:
here paste this into a file called where.
then type "chmod 755 where" in terminal
put the file somewhere in your path.
i use ~/bin for all my personal scripts and tools.
Code:
#!/bin/tcsh
if ($#argv > 0) then
foreach arg ($argv)
where $arg
end
else
echo "where: Too few arguments."
endif
Ya know, I never thought of running a script with tcsh as its shell. Awesome, though, and creative at that. Post number 1, too, what a way to start off, eh?
Thanks.
Originally posted by kvm_mkdb:
try 'type -a'
hth
Hey that's cool too... I had to check bash's manpage to figure it out. Usage: type -a ls Nice little bash built-in functionality.
|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jan 2002
Status:
Offline
|
|
I think you're looking for "whereis". Works for me.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
Originally posted by arocha:
I think you're looking for "whereis". Works for me.
The whereis command is similar to the which command in that it only returns the first binary found in your $PATH. That works fine for some cases, but say I wanted to find all of them:
Code:
[aorth@localhost: ~]$ whereis ls
/bin/ls
[aorth@localhost: ~]$ type -a ls
ls is aliased to `/usr/local/bin/ls --color'
ls is /bin/ls
ls is /usr/local/bin/ls
The second one is pretty sweet. 
|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Jul 2001
Location: NC
Status:
Offline
|
|
I'm hesitant to suggest this because I do it too much. Despite that, I think it's a good suggestion. The shell with the most features, zsh, has a "where" builtin command that behaves like that of tcsh. The most powerful feature of zsh is it's unbelievable completion mechanism. It understands context and syntax.
If I type:
ssh r<tab>
I get:
ssh root@
and if I type a w and another tab:
ssh root@w<tab>
I get
ssh root@ www.server.com:
That assumes that "root" is the only user starting with an "r", that no host start with an "r", and that "www.server.com" is the only host starting with a "w". Otherwise, I would get a list of the possibilities and successive <tab> keystrokes will cause zsh to cycle through the possibilities. This is known as menu completion. If all that's not enough, if you have public key authentication set up, zsh will actually do remote filename completion. It will do it anyway but will ask for your password first. That just isn't as much fun.
I have a set of zsh configuration scripts modeled after the tcsh configuration scripts of Wilfredo Sanchez Jr. You can find them at zsh.tar.gz. Unpack them in your home directory and follow the directions in the ~/Library/init/zsh/README file.
|
|
Gary
A computer scientist is someone who, when told to "Go to Hell", sees the
"go to", rather than the destination, as harmful.
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|