Reputation: 87
I'm trying to tool around with some scripts I have inherited at work and wanted to see if someone could decipher what this expression is attempting to accomplish:
|sed -e 's#\(.\{36\}\)\(.*\)#\1|\2#g' | sed -e 's#\(.\{49\}\)\(.*\)#\1|\2#g'
I have tried to reverse engineer this via the reference manuals and google, but have not been successful.
Thanks!
Upvotes: 0
Views: 218
Reputation: 15793
It means
insert after the first 36 chars of each line a '|'
in that ouput insert after the first 49 chars a '|'
all these insertions are done if the line contains at least 36 chars, respectively 49 chars.
you can do it shorter so:
| sed ' s:^.\{36\}:&|:; s:^.\{49\}:&|: '
Upvotes: 2
Reputation: 99094
This is two sed statements. The first inserts a pipe character ('|') after the first 36 characters of the line, the second inserts a pipe character after the first 49 characters (including the pipe it inserted in the first step).
As far as I can tell, these could be written more concisely with the same effect:
|sed -e 's#\(.\{36\}\)#\1|#' | sed -e 's#\(.\{49\}\)#\1|#'
Upvotes: 2