I need to hijack and modify a datastream. The stream consists of fixed-width commands. Each command is a new line, and the documentation says that each command starts and ends
Instead of the sed
command, you can use this:
perl -pe 's/(,\w+)/" " x length $1/ge'
The e
option on the substitution means that the right side of the s///
is evaluated as a Perl expression. In this case, the expression returns the correct number of spaces, based on the length of the captured match.