Unix 中命令可用的错误消息列表

cof*_*Mug 7 documentation exit-status

是否可以找出命令包含哪些错误消息?例如,我想查看mkfs.ext3command 在不同错误情况下将打印的错误消息列表。我应该查看源代码还是有其他方法可以实现这一目标?

slm*_*slm 7

源代码将是你最好的选择。您可以在紧要关头使用该命令strings来获取有关它可能包含的二进制文件和文本的一些基本概念。

例子

这是输出的前 20 行。这些是其中包含字符串“error”的行。

$ strings /usr/sbin/mkfs.ext3 | grep -i error | head -20
Syntax error in mke2fs config file (%s, line #%d)
Couldn't init profile successfully (error: %ld).
Error while enabling multiple mount protection feature.
MMP error info: last update: %s node: %s device: %s
Syntax error in profile section header
Syntax error in profile relation
[ERROR] %s:%d:%s:: Unable to allocate dquot
[ERROR] %s:%d:%s:: Cannot initialize io on quotafile
[ERROR] %s:%d:%s:: Cannot finish IO on new quotafile: %s
[ERROR] %s:%d:%s:: Unable to allocate quota handle
[ERROR] %s:%d:%s:: Failed to allocate quota context
[ERROR] %s:%d:%s:: Failed to allocate dictionary
[ERROR] %s:%d:%s:: while opening inode scan. ret=%ld
[ERROR] %s:%d:%s:: while getting next inode. ret=%ld
[ERROR] %s:%d:%s:: Open quota file failed
[ERROR] %s:%d:%s:: Error scanning dquots
[ERROR] %s:%d:%s:: ext2fs_file_llseek failed: %ld
[ERROR] %s:%d:%s:: ext2fs_file_read failed: %ld
[ERROR] %s:%d:%s:: ext2fs_file_write failed: %ld
[ERROR] %s:%d:%s:: ext2fs_file_open failed: %s
Run Code Online (Sandbox Code Playgroud)