If you want an answer that applies only to the mkdir command, simply
add the -p flag to show no errors when the folder exists.
On the other hand, if you want an answer that is applied in a general way to
hide error messages, you can make use of the flow redirection, whose
syntax is as follows:
[comando] [descriptor]>[archivo_al_que_redirigir]
[descriptor] is a number that represents a data flow. All process in unix
has at least three descriptors:
- 0 Standard input
- 1 Standard output
- 2 Standard error output
For what you can do, for example:
mkdir carpeta 2> archivo_errores.txt
To execute the mkdir command and, if it issues error messages, not display them
in the console but send them to the file called file_errors.txt (Which
it is created if it does not exist).
However, it is very likely that you do not want to keep the exit even in a
archive. For this purpose there is the special file / dev / null, also known
as a null peripheral, which discards all the information sent to it. Already
entered into this, you could also redirect the output contents
standard so that a command does not issue any message in the following way:
mkdir carpeta 1> /dev/null 2> /dev/null
Which can be abbreviated as:
mkdir carpeta 2&>1 > /dev/null
Where "2 & > 1" means "associates descriptor 2 (standard output) with the
descriptor 1 (standard error output) ".