reference
reference copied to clipboard
fix: sed line number incorrect
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.