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
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 .
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.
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.
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.
No, it isn't possible.
$x &> /dev/null
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With