|
From: | R. Diez |
Subject: | Re: Filtering out carriage returns from terminal progress indicators |
Date: | Sun, 17 Feb 2019 17:31:07 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 |
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
I just tested it, and it does not fit the bill. It suffers from the same memory consumption problem I described. I guess sed is reading the whole line until \n before applying the regular expression. Such a line can be huge if the output comes from a long-running rsync or similar tool.
Regards, rdiez
[Prev in Thread] | Current Thread | [Next in Thread] |