Skip to main content

Timeline for sed inplace in selective block

Current License: CC BY-SA 4.0

13 events
when toggle format what by license comment
Aug 31 at 14:40 comment added Ed Morton The difficulty in parsing that input only occurs when a string or a comment contains } or filter {. Add those cases to your sample input/expected output so we can help you create a solution that works for them, not just the sunny day cases you've shown so far.
S Aug 25 at 9:20 history suggested markp-fuso CC BY-SA 4.0
added highlight formatting; clarified that only the 'filter' block should be modified (per OP's comment)
Aug 22 at 19:36 review Suggested edits
S Aug 25 at 9:20
Aug 22 at 18:49 comment added Sollosa I meant only filter block @markp-fuso
Aug 22 at 16:02 answer added Stéphane Chazelas timeline score: 2
Aug 22 at 15:59 comment added Raffa You need to match multi-line to solve this ... The tools you're using, probably, can process multi-line with the -z option but that's not the best approach ... Some tools are better suited for this ... See for example Print content between first matching brackets
Aug 22 at 15:45 history edited Stéphane Chazelas CC BY-SA 4.0
formatting
Aug 22 at 14:05 history edited Sollosa CC BY-SA 4.0
added 2 characters in body
Aug 22 at 14:00 comment added Sollosa @markp-fuso this is exactly what I need to figure out opening/closing braces come in pair, so if an opening brace is there, it has to have ending brace but child blocks can start their own starting brace, so now expression needs to look for 2 closing braces, 1 for parent block & 1 for child, and this will repeat until final closing brace closing filter block.
Aug 22 at 13:57 history edited Sollosa CC BY-SA 4.0
added 2243 characters in body
Aug 22 at 13:51 comment added markp-fuso please update the question with a) sample input that demonstrates the different data sets you've mentioned (block w/ ending brace, block with no ending brace, nested blocks with/without ending brace), b) the expected result and c) the (grep, xargs, sed) code you've tried and the (wrong) results generated by said code; also verify if you want the original file updated (if you're piping the results of the grep to sed then that's a problem since sed is not working with the original file ... hence the need for more details as well as your current code)
Aug 22 at 13:48 comment added markp-fuso with a nested block and a missing brace, how do you determine which block the ending brace belongs to? for example: { outer { inner } ... does the ending brace belong to outer or inner?
Aug 22 at 13:38 history asked Sollosa CC BY-SA 4.0