reference icon indicating copy to clipboard operation
reference copied to clipboard

fix: sed line number incorrect

Open iNecas opened this issue 1 year ago • 0 comments

The original code for prefixing line numbers was not working, as it was adding less extra space than needed:

seq 3 | sed = | sed 'N; s/^/   /; s/ *\(.\{6,\}\)\n/\1/'
   1
1
   2
2
   3
3

Adding few more spaces fixes the issue:

seq 3 | sed = | sed 'N; s/^/     /; s/ *\(.\{6\}\)\n/\1 /'
     1 1
     2 2
     3 3

I've also changed \{6,\} to \{6\}, as the extra , shouln't be needed and might be confusing.

iNecas avatar Aug 22 '24 13:08 iNecas