"which" - where can I find it.

"which" - where can I find it.

Post by Bill Rober » Thu, 13 Jan 1994 13:48:08



I recently upgraded to slackware from a really old SLS setup and found
I no longer have "which" that tells me where in my path a file is.

I know its out there somewhere.  Can somebody tell me where.

Thanx....

Bill Roberts

--
| Bill Roberts --  working hard at | Is what your telling me what |
| becoming the worlds oldest geek! | you think, saw, or believe?? |

 
 
 

"which" - where can I find it.

Post by Daniel Quinl » Thu, 13 Jan 1994 17:06:16



> I recently upgraded to slackware from a really old SLS setup and found
> I no longer have "which" that tells me where in my path a file is.
> I know its out there somewhere.  Can somebody tell me where.

"which" is csh script from BSD. You can use tcsh to run this.  I would
create a symbolic link to tcsh from /bin/csh for stuff like this
(since there is no true csh for Linux).

------------------>8 cut here ----------------------------------------
#! /bin/csh -f
#

#
#       which : tells you which program you get
#
# Set prompt so .cshrc will think we're interactive and set aliases.
# Save and restore path to prevent .cshrc from messing it up.
set _which_saved_path_ = ( $path )
set prompt = ""
if ( -r ~/.cshrc && -f ~/.cshrc ) source ~/.cshrc
set path = ( $_which_saved_path_ )
unset prompt _which_saved_path_
set noglob
foreach arg ( $argv )
    set alius = `alias $arg`
    switch ( $#alius )
        case 0 :
            breaksw
        case 1 :
            set arg = $alius[1]
            breaksw
        default :
            echo ${arg}: " " aliased to $alius
            continue
    endsw
    unset found
    if ( $arg:h != $arg:t ) then
        if ( -e $arg ) then
            echo $arg
        else
            echo $arg not found
        endif
        continue
    else
        foreach i ( $path )
            if ( -x $i/$arg && ! -d $i/$arg ) then
                echo $i/$arg
                set found
                break
            endif
        end
    endif
    if ( ! $?found ) then
        echo no $arg in $path
    endif
end
------------------>8 cut here ----------------------------------------

--


 
 
 

"which" - where can I find it.

Post by Hans de Vreug » Thu, 13 Jan 1994 19:18:53




>> I recently upgraded to slackware from a really old SLS setup and found
>> I no longer have "which" that tells me where in my path a file is.
>"which" is csh script from BSD. You can use tcsh to run this.  I would
>create a symbolic link to tcsh from /bin/csh for stuff like this
>(since there is no true csh for Linux).

It is a *builtin* in tcsh (just like where)! If you use bash either do:
   tcsh -c 'which program'
or write the script:
   #!/bin/tcsh
   which $*
If you use tcsh anyway, just type 'which program'.
--
Hans de Vreught                  | John von Neumann:

Delft University of Technology   | you don't understand things,
The Netherlands                  | you just get used to them.
 
 
 

"which" - where can I find it.

Post by Daniel Quinl » Thu, 13 Jan 1994 20:47:36



>>> I recently upgraded to slackware from a really old SLS setup and found
>>> I no longer have "which" that tells me where in my path a file is.

>> "which" is csh script from BSD. You can use tcsh to run this.  I would
>> create a symbolic link to tcsh from /bin/csh for stuff like this
>> (since there is no true csh for Linux).


Quote:> It is a *builtin* in tcsh (just like where)! If you use bash either do:
>    tcsh -c 'which program'
> or write the script:
>    #!/bin/tcsh
>    which $*
> If you use tcsh anyway, just type 'which program'.

Good point, however someone did have to tell the gentleman that it was
a csh script...  In any case, there is a better way to do it in bash.

$ alias which='type -path'
$ which ls
/bin/ls

--

 
 
 

"which" - where can I find it.

Post by David Holla » Thu, 13 Jan 1994 14:02:13


 > "which" is csh script from BSD. You can use tcsh to run this.  I would
 > create a symbolic link to tcsh from /bin/csh for stuff like this
 > (since there is no true csh for Linux).

Silly, silly. 'which' is also built in to tcsh...

Bash users can alias which to "type -path", which works on binaries
but not on shell builtins or aliases. There may be a better way; I
don't use bash much.

--
   - David A. Holland             | Nobody ever went broke underestimating

 
 
 

"which" - where can I find it.

Post by Greg Patt » Fri, 14 Jan 1994 15:10:54



>I recently upgraded to slackware from a really old SLS setup and found
>I no longer have "which" that tells me where in my path a file is.

In tcsh.6.04...

[5:09pm]~ 30%which which
which: shell built-in command.
--
Greg Patten                                              Melbourne, Australia

 
 
 

"which" - where can I find it.

Post by Benjamin Weste Pear » Wed, 19 Jan 1994 13:47:47


In bash, at least, and I think in tcsh as well, "type -path <filename>
does a good imitation of "which" although it seems not to want to
learn about aliases.  There is probably some way around this...