|
From: | Paolo Bonzini |
Subject: | Re: manual: a wrong description in sample scripts |
Date: | Fri, 27 May 2011 09:49:33 +0200 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.10 |
On 05/26/2011 08:29 PM, Micah Cowan wrote:
(05/25/2011 10:31 PM), wu liang wrote:Sir, In the chapter "4.2 Increment a Number", it is said " The tn commands are not necessary, but make the thing faster". However it is not correct in case that all the digits is 9. For example, 999 will not get result of 1000 but 2000, if there is no tn command,since it will be addressed again in the following s command.Yup. It also strikes me that the comment # replace all leading 9s by _ (any other character except digits, could # be used) :d s/9\(_*\)$/_\1/ td is incorrect, since "leading" should mean the left-most digits, whereas this code is clearly replacing the right-most (trailing) digits.
I fixed both issues, thanks.Regarding Wu's reported problem, in fact all but the first "tn" are unnecessary, and you can change the replacement from 1 to 0 in the first to eliminate the first "tn" as well. This may be useful with sed implementations that have a hard limit on the number of commands.
Paolo
[Prev in Thread] | Current Thread | [Next in Thread] |