Calculate the string length in sed
问题 I was forced to calculate the string length in sed . The string is always a nonempty sequence of a 's. sed -n ':c /a/! be; s/^a/1/; s/0a/1/; s/1a/2/; s/2a/3/; s/3a/4/; s/4a/5/; s/5a/6/; s/6a/7/; s/7a/8/; s/8a/9/; s/9a/a0/; /a/ bc; :e p' It's quite long :) So now I wonder if it is possible to rewrite this script more concisely using the y or other sed command? I know that it is better to use awk or another tool. However, this is not a question here. Note that the sed script basically simulates