LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-01-2021, 10:06 PM   #1
crajor
Member
 
Registered: Mar 2019
Location: Akron, Ohio
Distribution: PCLinuxOS 2020
Posts: 91
Blog Entries: 4

Rep: Reputation: Disabled
For me, strange results from a 'pipe' command


OK so I typed this command into a terminal
[CODE]man dmesg > kmsgcmd[CODE]
Sure enough, there is now a kmsgcmd in my home directory, but this is my output from the command:
[QUOTE]DMESG(1) User Commands DMESG(1)



NNAAMMEE
dmesg - print or control the kernel ring buffer

SSYYNNOOPPSSIISS
ddmmeessgg [options]

ddmmeessgg ----cclleeaarr
ddmmeessgg ----rreeaadd--cclleeaarr [options]
ddmmeessgg ----ccoonnssoollee--lleevveell _l_e_v_e_l
ddmmeessgg ----ccoonnssoollee--oonn
ddmmeessgg ----ccoonnssoollee--ooffff

DDEESSCCRRIIPPTTIIOONN
ddmmeessgg is used to examine or control the kernel ring buffer.

The default action is to display all messages from the kernel ring buf‐
fer.

OOPPTTIIOONNSS
The ----cclleeaarr, ----rreeaadd--cclleeaarr, ----ccoonnssoollee--oonn, ----ccoonnssoollee--ooffff, and ----ccoonn‐‐
ssoollee--lleevveell options are mutually exclusive.

--CC, ----cclleeaarr
Clear the ring buffer.

--cc, ----rreeaadd--cclleeaarr
Clear the ring buffer after first printing its contents.

--DD, ----ccoonnssoollee--ooffff
Disable the printing of messages to the console.

--dd, ----sshhooww--ddeellttaa
Display the timestamp and the time delta spent between messages.
If used together with ----nnoottiimmee then only the time delta without
the timestamp is printed.

--EE, ----ccoonnssoollee--oonn
Enable printing messages to the console.

--ee, ----rreellttiimmee
Display the local time and the delta in human-readable format.
Be aware that conversion to the local time could be inaccurate
(see --TT for more details).

--FF, ----ffiillee _f_i_l_e
Read the syslog messages from the given _f_i_l_e. Note that --FF does
not support messages in kmsg format. The old syslog format is
supported only.

--ff, ----ffaacciilliittyy _l_i_s_t
Restrict output to the given (comma-separated) _l_i_s_t of facili‐
ties. For example:

ddmmeessgg ----ffaacciilliittyy==ddaaeemmoonn

will print messages from system daemons only. For all supported
facilities see the ----hheellpp output.

--HH, ----hhuummaann
Enable human-readable output. See also ----ccoolloorr, ----rreellttiimmee and
----nnooppaaggeerr.

--kk, ----kkeerrnneell
Print kernel messages.

--LL, ----ccoolloorr[=_w_h_e_n]
Colorize the output. The optional argument _w_h_e_n can be aauuttoo,
nneevveerr or aallwwaayyss. If the _w_h_e_n argument is omitted, it defaults
to aauuttoo. The colors can be disabled; for the current built-in
default see the ----hheellpp output. See also the CCOOLLOORRSS section be‐
low.

--ll, ----lleevveell _l_i_s_t
Restrict output to the given (comma-separated) _l_i_s_t of levels.
For example:

ddmmeessgg ----lleevveell==eerrrr,,wwaarrnn

will print error and warning messages only. For all supported
levels see the ----hheellpp output.

--nn, ----ccoonnssoollee--lleevveell _l_e_v_e_l
Set the _l_e_v_e_l at which printing of messages is done to the con‐
sole. The _l_e_v_e_l is a level number or abbreviation of the level
name. For all supported levels see the ----hheellpp output.

For example, --nn 11 or --nn eemmeerrgg prevents all messages, except
emergency (panic) messages, from appearing on the console. All
levels of messages are still written to _/_p_r_o_c_/_k_m_s_g, so ssyyss‐‐
llooggdd(8) can still be used to control exactly where kernel mes‐
sages appear. When the --nn option is used, ddmmeessgg will _n_o_t print
or clear the kernel ring buffer.

----nnooeessccaappee
The unprintable and potentially unsafe characters (e.g., broken
multi-byte sequences, terminal controlling chars, etc.) are es‐
caped in format \x<hex> for security reason by default. This
option disables this feature at all. It's usable for example for
debugging purpose together with ----rraaww. Be careful and don't use
it by default.

--PP, ----nnooppaaggeerr
Do not pipe output into a pager. A pager is enabled by default
for ----hhuummaann output.

--pp, ----ffoorrccee--pprreeffiixx
Add facility, level or timestamp information to each line of a
multi-line message.

--rr, ----rraaww
Print the raw message buffer, i.e., do not strip the log-level
prefixes, but all unprintable characters are still escaped (see
also ----nnooeessccaappee).

Note that the real raw format depends on the method how ddmmeessgg(1)
reads kernel messages. The /dev/kmsg device uses a different
format than ssyysslloogg(2). For backward compatibility, ddmmeessgg(1) re‐
turns data always in the ssyysslloogg(2) format. It is possible to
read the real raw data from /dev/kmsg by, for example, the com‐
mand 'dd if=/dev/kmsg iflag=nonblock'.

--SS, ----ssyysslloogg
Force ddmmeessgg to use the ssyysslloogg(2) kernel interface to read kernel
messages. The default is to use /dev/kmsg rather than ssyysslloogg(2)
since kernel 3.5.0.

--ss, ----bbuuffffeerr--ssiizzee _s_i_z_e
Use a buffer of _s_i_z_e to query the kernel ring buffer. This is
16392 by default. (The default kernel syslog buffer size was
4096 at first, 8192 since 1.3.54, 16384 since 2.1.113.) If you
have set the kernel buffer to be larger than the default, then
this option can be used to view the entire buffer.

--TT, ----ccttiimmee
Print human-readable timestamps.

BBee aawwaarree tthhaatt tthhee ttiimmeessttaammpp ccoouulldd bbee iinnaaccccuurraattee!! The ttiimmee
source used for the logs is nnoott uuppddaatteedd aafftteerr system SSUUSSPPEENNDD/RREE‐‐
SSUUMMEE. Timestamps are adjusted according to current delta be‐
tween boottime and monotonic clocks, this works only for mes‐
sages printed after last resume.

--tt, ----nnoottiimmee
Do not print kernel's timestamps.

----ttiimmee--ffoorrmmaatt _f_o_r_m_a_t
Print timestamps using the given _f_o_r_m_a_t, which can be ccttiimmee,
rreellttiimmee, ddeellttaa or iissoo. The first three formats are aliases of
the time-format-specific options. The iissoo format is a ddmmeessgg im‐
plementation of the ISO-8601 timestamp format. The purpose of
this format is to make the comparing of timestamps between two
systems, and any other parsing, easy. The definition of the iissoo
timestamp is: YYYY-MM-DD<T>HH:MM:SS,<microseconds><-+><timezone
offset from UTC>.

The iissoo format has the same issue as ccttiimmee: the time may be in‐
accurate when a system is suspended and resumed.

--uu, ----uusseerrssppaaccee
Print userspace messages.

--ww, ----ffoollllooww
Wait for new messages. This feature is supported only on sys‐
tems with a readable /dev/kmsg (since kernel 3.5.0).

--WW, ----ffoollllooww--nneeww
Wait and print only new messages.

--xx, ----ddeeccooddee
Decode facility and level (priority) numbers to human-readable
prefixes.

--VV, ----vveerrssiioonn
Display version information and exit.

--hh, ----hheellpp
Display help text and exit.

CCOOLLOORRSS
Implicit coloring can be disabled by an empty file _/_e_t_c_/_t_e_r_m_i_n_a_l_-_c_o_l_‐
_o_r_s_._d_/_d_m_e_s_g_._d_i_s_a_b_l_e. See tteerrmmiinnaall--ccoolloorrss..dd(5) for more details about
colorization configuration.

The logical color names supported by ddmmeessgg are:

ssuubbssyyss The message sub-system prefix (e.g., "ACPI:").

ttiimmee The message timestamp.

ttiimmeebbrreeaakk
The message timestamp in short ctime format in ----rreellttiimmee or
----hhuummaann output.

aalleerrtt The text of the message with the alert log priority.

ccrriitt The text of the message with the critical log priority.

eerrrr The text of the message with the error log priority.

wwaarrnn The text of the message with the warning log priority.

sseeggffaauulltt
The text of the message that inform about segmentation fault.

EEXXIITT SSTTAATTUUSS
ddmmeessgg can fail reporting permission denied error. This is usually
caused by ddmmeessgg__rreessttrriicctt kernel setting, please see ssyysslloogg(2) for more
details.

AAUUTTHHOORRSS
Karel Zak ⟨kzak@redhat.com⟩

ddmmeessgg was originally written by Theodore Ts'o ⟨tytso@athena.mit.edu⟩

SSEEEE AALLSSOO
tteerrmmiinnaall--ccoolloorrss..dd(5), ssyyssllooggdd(8)

AAVVAAIILLAABBIILLIITTYY
The dmesg command is part of the util-linux package and is available
from Linux Kernel Archive ⟨https://www.kernel.org/pub/linux/utils/util-
linux/⟩.



util-linux July 2012 DMESG(1)[QUOTE]
Am I seeing something particular to a font? Editing this file is really not feasible, but I do not know how to deal with this situation. Any help would be appreciated.

Last edited by crajor; 01-01-2021 at 10:10 PM. Reason: CODE and QUOTE tags
 
Old 01-01-2021, 10:40 PM   #2
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,979

Rep: Reputation: 271Reputation: 271Reputation: 271
troff/groff/nroff
 
Old 01-02-2021, 01:58 AM   #3
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,688

Rep: Reputation: Disabled
It's not a font. nroff produces a bold character C by C<BS>C and an underlined C by _<BS>C. Think of it as of output going to the dot-matrix printer. Try man -H dmesg instead.

Last edited by shruggy; 01-03-2021 at 03:39 AM.
 
Old 01-02-2021, 04:45 AM   #4
crajor
Member
 
Registered: Mar 2019
Location: Akron, Ohio
Distribution: PCLinuxOS 2020
Posts: 91

Original Poster
Blog Entries: 4

Rep: Reputation: Disabled
still not getting expected output

First of all, thanks very much for your replies. when I type in a terminal

Code:
man -H dmesg > krnmsgcmd
I only receive a question

Quote:
what manual page do you want?
trying the command without the pipe

Code:
man -H dmesg
shows the dmesg -help. I see no 'H' as an option.
 
Old 01-02-2021, 04:55 AM   #5
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,767

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Cool

man pages contain “control” characters to manage highlighting, etc. when being displayed. The redirect (not pipe) is passing them into the file.

What, exactly, are you trying to accomplish? Why are you redirecting the output of the man page to a file?
 
Old 01-02-2021, 05:00 AM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Does your man have a man page?
I am reading it now, and it seems that what you want is not as straightforward as one would hope.
OTOH, it should also be possible to display man pages with other commands, as suggested in post #2.
 
Old 01-02-2021, 05:11 AM   #7
crajor
Member
 
Registered: Mar 2019
Location: Akron, Ohio
Distribution: PCLinuxOS 2020
Posts: 91

Original Poster
Blog Entries: 4

Rep: Reputation: Disabled
used another method and got result

Did an online search

Quote:
man dmesg
and opened the man page in the results listed, copied from browser into a text editor and saved.

More than one way to skin a cat, as they say.

Thanks to all for your help and info. Marking this as solved.
 
Old 01-02-2021, 05:38 AM   #8
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
I just remembered a simple hack:
Code:
man man | ul > file
 
1 members found this post helpful.
Old 01-02-2021, 11:54 PM   #9
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,979

Rep: Reputation: 271Reputation: 271Reputation: 271
Hmmm... I just tried this and didn't get crajor's result. In any case, as man man will tell you, man pages are encoded in roff, a program that formatted text for dot-matrix printers, which achieved bold-ness by backspacing and printing the character again, underlining by backspacing then printing a _ - you can guess other practices or read roff's man page. That's what you saw when you captured dmesg's man page. Piping through n/g/troff (different platforms use different versions?) will translate back. For instance:
Code:
 man dmesg | groff > kmsgscmd
ondoho's tip only takes care of underlines.
 
Old 01-03-2021, 05:44 AM   #10
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by RandomTroll View Post
ondoho's tip only takes care of underlines.
One might think so.
But did you try it?
It takes care of much more.
Result: nicely formatted text-only man page. See here.
 
Old 01-04-2021, 08:06 AM   #11
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,979

Rep: Reputation: 271Reputation: 271Reputation: 271
Quote:
Originally Posted by ondoho View Post
One might think so.
But did you try it?
It takes care of much more.
Result: nicely formatted text-only man page. See here.
I get a correctly-formatted man page even when I do what crajor wrote he did,so I can't really test it. I took ul's man page at its word.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to handle a broken pipe exception (SIGPIPE) in FIFO pipe? zyroot998 Programming 5 03-03-2011 08:10 PM
PING .... pipe 2 vs pipe 3 hanen03 Linux - Networking 1 04-10-2009 10:50 AM
pipe using no pipe soathana Programming 2 02-22-2003 04:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration