我已经创建了一个 shell,当我给 cp
命令提供了错误数量的参数(例如参数不足)时,我收到了 Linux shell 错误消息,就像您在键入 cp fork 时收到的消息一样。 c
如下:
mysh> cp fork.c
cp: missing destination file operand after `fork.c'
Try `cp --help' for more information.
如何绕过此错误消息并打印我自己的错误消息,如 Dude!这是一个错误
?
最佳答案
cp fork.c > /dev/null 2>&1 || echo "Dude! this is an error"
关于c - 如何用我定义的错误消息替换 Linux 内核错误消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19073801/