in reply to [OT] 'perl' is not the 'perl' reported by 'which perl'

This might be caused by bash's hashing. Like this:

jo@bear$ PATH=/home/jo/bin:/usr/local/bin:/usr/bin:/bin jo@bear$ cat <<EOF >tellme.sh > #!/bin/bash > echo this is tellme.sh from /usr/local/bin > EOF jo@bear$ chmod +x tellme.sh jo@bear$ sudo cp tellme.sh /usr/local/bin jo@bear$ which tellme.sh /usr/local/bin/tellme.sh jo@bear$ tellme.sh this is tellme.sh from /usr/local/bin jo@bear$ cat <<EOF >tellme.sh > #!/bin/bash > echo this is tellme.sh from ~/bin EOF jo@bear$ cp tellme.sh bin jo@bear$ which tellme.sh /home/jo/bin/tellme.sh jo@bear$ tellme.sh this is tellme.sh from /usr/local/bin jo@bear$ hash -d tellme.sh jo@bear$ tellme.sh this is tellme.sh from /home/jo/bin

Greetings,
-jo

$gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$

Replies are listed 'Best First'.
Re^2:[OT] 'perl' is not the 'perl' reported by 'which perl'
by LanX (Saint) on Aug 21, 2020 at 17:46 UTC
        "... most people use the which command and have never even heard of the type command! ..."

        That's very interesting. I've used quite an array of shells since the '80s (sh, ksh, bash, csh, tcsh, and others). I'm reasonably certain I've used which almost exclusively. I couldn't definitely say I've never heard of type but, had I been asked about it yesterday, I would have had to look it up. I decided to look into this a bit further.

        There appears to be some redundant information (<some-command> is) with type; however, in isolation that doesn't appear to be a problem.

        $ which perl /.../perl $ type perl perl is /.../perl

        I did encounter an issue in this scenario:

        $ ls -l `which perl` -rwxr-xr-x 2 ken None 169225 Jun 23 20:35 /.../perl $ ls -l `type perl` ls: cannot access 'perl': No such file or directory ls: cannot access 'is': No such file or directory -rwxr-xr-x 2 ken None 169225 Jun 23 20:35 /.../perl

        On the other hand, it's particularly useful here:

        $ which perle which: no perle in (...) $ type perle perle is aliased to `perl -Mstrict -Mwarnings -Mautodie=:all -MCarp::A +lways -E'

        So, it looks like both commands have their uses in different situations. I will remember type from now on and use it where needed. Thanks for pointing out this command. [Edit: Actually, it looks like LanX was the first to mention type, so thanks Rolf.]

        [In case anyone was wondering, the /.../perl represents identical pathnames throughout. With "perlbrew", those paths are long and would probably wrap.]

        — Ken

        I've been an SA for like 10 years and never knew that until now. When I think type, I think DOS / windows cat command. Seems to still work in powershell:

        PS C:\Users\Dubs> get-Command type,cat,where,gm,help,get-help CommandType Name Version Source ----------- ---- ------- ------ Alias type -> Get-Content Alias cat -> Get-Content Alias where -> Where-Object Alias gm -> Get-Member Function help Cmdlet Get-Help 3.0.0.0 Microsoft.PowerSh +ell.Core

        Looks like zsh and csh alias to whence -v.