Re: OT - rm different on Ubuntu than Fedora

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jan 20, 2018 at 5:30 AM, Patrick O'Callaghan
<pocallaghan@xxxxxxxxx> wrote:
> On Sat, 2018-01-20 at 04:34 -0500, Tom H wrote:
>> On Sat, Jan 20, 2018 at 2:10 AM, Cameron Simpson <cs@xxxxxxxxxx> wrote:
>>>
>>> Also: "which rm" should show what executable is being used, and the
>>> bash "which" IIRC also shows if an alias or function is involved (I'm
>>> a zsh person myself).
>>
>> There's no "which" builtin in bash. IIRC, only tcsh and zsh have one.
>
> Personally I just use 'type' rather than 'which'.

"type" is the shortest and, like the others, it works for most commands.

"command", "type", "which" as well as "where" in tcsh and zsh,
"whence" in *ksh, "whereis" from util-linux all have their
peculiarities.


"command" and "type" list the first hit in the order of command expansion:

aliases > functions > builtins > first hit in $PATH


"type -a" lists all hits in the order of command expansion.


"which" only checks $PATH and lists the first hit.

"which -a" only checks $PATH and lists all hits in the order of $PATH expansion.

(GNU "which", used on Fedora, has an option for aliases.)


So you end up with edge cases. The output below is from my Mac because
I'm out and not ssh'd into a Linux system:

$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)
Copyright (C) 2007 Free Software Foundation, Inc.

$ echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin



$ sudo ln -s /bin/echo /usr/local/bin/echo
$ alias echo='/bin/echo -n'



$ which echo
/usr/local/bin/echo

$ which -a echo
/usr/local/bin/echo
/bin/echo

$ type echo
echo is aliased to `/bin/echo -n'

$ type -a echo
echo is aliased to `/bin/echo -n'
echo is a shell builtin
echo is /usr/local/bin/echo
echo is /bin/echo

$ command -v echo
alias echo='/bin/echo -n'

$ command -V echo
echo is aliased to `/bin/echo -n'



$ unalias echo



$ which echo
/usr/local/bin/echo

$ which -a echo
/usr/local/bin/echo
/bin/echo

$ type echo
echo is a shell builtin

$ type -a echo
echo is a shell builtin
echo is /usr/local/bin/echo
echo is /bin/echo

$ command -v echo
echo

$ command -V echo
echo is a shell builtin



$ sudo rm /usr/local/bin/echo



$ which echo
/bin/echo

$ which -a echo
/bin/echo

$ type echo
echo is a shell builtin

$ type -a echo
echo is a shell builtin
echo is /bin/echo

$ command -v echo
echo

$ command -V echo
echo is a shell builtin

$
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux