sed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Filtering out carriage returns from terminal progress indicators


From: Assaf Gordon
Subject: Re: Filtering out carriage returns from terminal progress indicators
Date: Sun, 17 Feb 2019 09:18:24 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

Hello,

On 2019-02-17 3:15 a.m., R. Diez wrote:
[...]
"The log file should optimise away the carriage return trick often used to update a progress indicator in place on the current console line."

[...]

It would not be a perfect filtering, but it could be enough. This is a problematic case:

echo $'123\rab\n'

The result should be:

ab3

But the filtering I am proposing would output:

ab


Something like this should do the trick:

  $ printf '123\r456\r789\rab\n000\r111\r222\r333\rcd\n' \
         | LC_ALL=C sed 's/[^\r]*\r//g'
  ab
  cd

regards,
 - assaf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]