如何突出显示警告信息?

如何突出显示警告信息?

我想要突出运行特定命令时会出现警告消息。如果我们不小心运行了某些特定命令(它可能正在删除必要的系统包),它会在即将要执行的操作之前显示一些警告信息。

但是警告信息不是高亮显示的,有些人可能会读到警告信息并取消操作,但有些人可能会不看警告信息就执行命令,最终导致系统崩溃。

示例 1:

avinash@linux:~$ sudo apt-get purge firefox
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  firefox* lightdm-remote-session-uccsconfigure* xul-ext-unity* xul-ext-webaccounts*
0 upgraded, 0 newly installed, 4 to remove and 300 not upgraded.
After this operation, 63.1 MB disk space will be freed.
Do you want to continue [Y/n]?

在上面的例子中,不需要警告信息。因为firefox它不是必需的包。如果我们删除 Firefox 包,系统也会顺利运行。

示例 2:

avinash@linux:~$ sudo apt-get purge hostname
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  hostname*
WARNING: The following essential packages will be removed.
This should NOT be done unless you know exactly what you are doing!
  hostname
0 upgraded, 0 newly installed, 1 to remove and 301 not upgraded.
After this operation, 85.0 kB disk space will be freed.
You are about to do something potentially harmful.
To continue type in the phrase 'Yes, do as I say!'
 ?] 

在这个例子中,该hostname包是一个必需的重要包。如果你删除这个包,你的系统就会崩溃。

那么,可以突出显示吗(红色或粗体文字) 如果该命令旨在在执行特定操作之前生成警告消息,那么是否仅显示警告消息?

WARNING: The following essential packages will be removed.
This should NOT be done unless you know exactly what you are doing!

相关内容