Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > tcsh built-in "where"

tcsh built-in "where"
Thread Tools
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status: Offline
Reply With Quote
May 5, 2004, 12:13 PM
 
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
Reply With Quote
May 5, 2004, 12:40 PM
 
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
Reply With Quote
May 5, 2004, 05:11 PM
 
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
Reply With Quote
May 5, 2004, 05:21 PM
 
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
Reply With Quote
May 6, 2004, 01:23 AM
 
You're ok in my book, phil.

"In Nomine Patris, Et Fili, Et Spiritus Sancti"

     
Junior Member
Join Date: May 2004
Status: Offline
Reply With Quote
May 8, 2004, 12:34 PM
 
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
Reply With Quote
May 8, 2004, 05:46 PM
 
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
Reply With Quote
May 9, 2004, 05:05 AM
 
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
Reply With Quote
May 9, 2004, 08:18 AM
 
I think you're looking for "whereis". Works for me.
     
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status: Offline
Reply With Quote
May 10, 2004, 11:20 AM
 
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
Reply With Quote
May 10, 2004, 11:44 PM
 
   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.

&nbsp;&nbsp;&nbsp;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.
     
   
Thread Tools
Forum Links
Forum 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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:38 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2