0

I want to remove echo command (which is located in /bin/echo), but the command echo still work as normal. When I use which command, it confirm that echo was removed

/usr/bin/which: no echo in (/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)

Do you know what's happening

  • 1
    Use type echo instead of which echo when debugging. While the reason here is the built-in, in a similar scenario command path cache might also interfere. – techraf Mar 13 '17 at 2:53
1

bash is also a builtin from your shell (e.g bash, ksh etc.) so even if you remove the original echo binary, it will still work from your shell (but you will not have the arguments etc. available like with the binary)

see the bash builtins here : http://www.gnu.org/software/bash/manual/html_node/Bash-Builtins.html

try to add this in the user .bash_profile (or from the shell) :

enable -p echo

and try to run echo again (ref : https://astoryworthtelling.wordpress.com/2011/03/20/disable-bash-builtin-commands/) and it shouldn't work

| improve this answer | |
  • -p prints the state. You wanted to suggest -n. – techraf Mar 13 '17 at 2:44
  • I did not fix, I do not edit others' code on SO. Please do it yourself. – techraf Mar 13 '17 at 12:46
2

Echo is a bash builtin command, which is what you're seeing.

I guess the real question is: why do you want to do this? There are many, many programs that rely on echo, all of which will break if you disable this command.

| improve this answer | |
  • I have a program, which using echo command to interact with system, and I want to test for all the case – Waveter Mar 12 '17 at 13:38
0

This is actually a great demonstration of why it's a bad idea to use echo in scripts that you want to be portable. It's often overridden by shell built ins.

Have a look at

man bash

And search for echo to find where the built in version is defined.

| improve this answer | |
0

Depending on your need, you can still override echo with an alias

alias echo=':'
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.