yum
and dnf
write progress messages, overstriking a line by using carriage returns. Those messages are not wrapped. grep
is not designed for that, assuming lines do not have embedded control characters. grep
does make some assumptions about terminals, but that's a different story.
I use a sed script for filtering the overstruck lines to a "final" line (deleting all of the overstruck part). In the example script2log.sed
,
# $Id: script2log.sed,v 1.3 2015/02/04 23:50:12 tom Exp $
#
# Trim ordinary ANSI sequences, then OSC sequences, then backspace
# sequences, then trailing CR's and finally overstruck sections of
# lines.
#
# There are still several interesting cases which cannot be handled
# with a script of this sort. For example:
# CSI K (clear line)
# cursor movement within the line
s/␛[[][<=>?]\{0,1\}[;0-9]*[@-~]//g
s/␛[]][^␛]*␇//g
s/␛[]][^␛]*␛\\//g
:loop
s/[^␈]␈\(.\)/\1/g
t loop
s/␍␍*$//g
s/^.*␍//g
s/␛[^[]//g
that is done with these two commands, which first removes any number of trailing carriage returns on a line, and then removes any section of the line including a carriage return. What is left is only the last copy of the line to be written (the one you want):
s/␍␍*$//g
s/^.*␍//g
(and yes, those are literal carriage return characters in the script).
When I capture output from yum
(or dnf
), I do not try piping to grep
(that is guaranteed to produce poor results). Rather, I use script
to capture the output, and post-process that using sed
, e.g.,
script -c "yum upgrade"
sed -f script2log.sed typescript >upgrade.log
Best Answer
I think you will probably have the cleanest experience by not bothering to funnel the software through RPM; just build it locally into
/opt
or/usr/local
.But, if you really want it, there's FPM, which will create a quick and dirty package from just about anything. Find it at https://github.com/jordansissel/fpm.