Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn off echo while executing a shell script Linux [duplicate]

Here is a simple thing i was working on

 echo "please enter a command"
 read x
 $x
 checkexitstatus()
 {...}

checkexit status is a ifloop created somewhere else just to check exit status

What i want to know is Is there any way that when i run the $x that it wont be displayed on the screen I want to know if it is possible without redirecting the output to a file

like image 965
AkyJ Avatar asked Apr 27 '14 07:04

AkyJ


People also ask

How do I turn off echo in Linux?

echo "please enter a command" read x $x checkexitstatus() {...} $x > /dev/null instead of $x . To silence error messages too, $x > /dev/null 2>&1 . @AkyJ If you want to store the output to a file, you should use something else than /dev/null .

How do you stop echo in bash?

If you are looking to suppress or hide all the output of a bash shell script from Linux command line as well as from the crontab then you can simply redirect all the output to a file known as /dev/null . This file is known as Black Hole which will engulf everything you give without complaining.

What does echo $$ do in Linux?

Echo is a Unix/Linux command tool used for displaying lines of text or string which are passed as arguments on the command line. This is one of the basic command in linux and most commonly used in shell scripts.

How do you run a command silently in Linux?

To silence the output of a command, we redirect either stdout or stderr — or both — to /dev/null. To select which stream to redirect, we need to provide the FD number to the redirection operator.


2 Answers

No, it isn't possible.

$x &> /dev/null
like image 178
Ignacio Vazquez-Abrams Avatar answered Sep 20 '22 08:09

Ignacio Vazquez-Abrams


If you want to turn off only the echo command and not other commands that send their output to the stdout, as the title suggests, you can possibly (it may break the code) create an alias for echo

alias echo=':'

now echo is an alias for noop. You can unalias it by unalias echo.

like image 36
a5hk Avatar answered Sep 23 '22 08:09

a5hk