How to implement sed range pattern command on groovy script

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I'm struggling to implement the sed range pattern command on groovy script.



This is how I'm attempting to implement the command in groovy script:



 def range = sed -n -e '/Word A/,/Word D/ p'
def result = cat sample.txt | range.execute()


This is the content of the sample.txt file:



Word A
Word B
Word C
Word D
Word E
Word F


This is the output I want:



Word A
Word B
Word C
Word D


Now, the error that is returned to me when I run it is:



sed: unmatched '/'


I believe the reason why I'm getting this error is because in the actual sed command, I need to somehow group the range pattern altogether because I feel and in fact I've tested it, the sed command only applies to the first range, i.e. "WORD A" and then it reads the next "/" as a literal character rather than a character that encapsulates the next pattern which is WORD D.



I've tried to use single quotes and double quotes but upon running my script, I get an error saying either: sed unmatched "'" or sed unknown command.



Can someone please help resolve this issue as it's taken me two days to work this out.



Thanks!










share|improve this question

















  • 1




    What's the difference to your other, recent question? Same error - how did you resolve it?
    – RudiC
    Sep 22 at 10:56










  • The solution provided didn't resolve the issue. Rather, I've been able to pinpoint whats causing the issue, I just don't know how to resolve it as I've tried different ways of grouping the range
    – Ahmad
    Sep 22 at 10:59














up vote
0
down vote

favorite












I'm struggling to implement the sed range pattern command on groovy script.



This is how I'm attempting to implement the command in groovy script:



 def range = sed -n -e '/Word A/,/Word D/ p'
def result = cat sample.txt | range.execute()


This is the content of the sample.txt file:



Word A
Word B
Word C
Word D
Word E
Word F


This is the output I want:



Word A
Word B
Word C
Word D


Now, the error that is returned to me when I run it is:



sed: unmatched '/'


I believe the reason why I'm getting this error is because in the actual sed command, I need to somehow group the range pattern altogether because I feel and in fact I've tested it, the sed command only applies to the first range, i.e. "WORD A" and then it reads the next "/" as a literal character rather than a character that encapsulates the next pattern which is WORD D.



I've tried to use single quotes and double quotes but upon running my script, I get an error saying either: sed unmatched "'" or sed unknown command.



Can someone please help resolve this issue as it's taken me two days to work this out.



Thanks!










share|improve this question

















  • 1




    What's the difference to your other, recent question? Same error - how did you resolve it?
    – RudiC
    Sep 22 at 10:56










  • The solution provided didn't resolve the issue. Rather, I've been able to pinpoint whats causing the issue, I just don't know how to resolve it as I've tried different ways of grouping the range
    – Ahmad
    Sep 22 at 10:59












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm struggling to implement the sed range pattern command on groovy script.



This is how I'm attempting to implement the command in groovy script:



 def range = sed -n -e '/Word A/,/Word D/ p'
def result = cat sample.txt | range.execute()


This is the content of the sample.txt file:



Word A
Word B
Word C
Word D
Word E
Word F


This is the output I want:



Word A
Word B
Word C
Word D


Now, the error that is returned to me when I run it is:



sed: unmatched '/'


I believe the reason why I'm getting this error is because in the actual sed command, I need to somehow group the range pattern altogether because I feel and in fact I've tested it, the sed command only applies to the first range, i.e. "WORD A" and then it reads the next "/" as a literal character rather than a character that encapsulates the next pattern which is WORD D.



I've tried to use single quotes and double quotes but upon running my script, I get an error saying either: sed unmatched "'" or sed unknown command.



Can someone please help resolve this issue as it's taken me two days to work this out.



Thanks!










share|improve this question













I'm struggling to implement the sed range pattern command on groovy script.



This is how I'm attempting to implement the command in groovy script:



 def range = sed -n -e '/Word A/,/Word D/ p'
def result = cat sample.txt | range.execute()


This is the content of the sample.txt file:



Word A
Word B
Word C
Word D
Word E
Word F


This is the output I want:



Word A
Word B
Word C
Word D


Now, the error that is returned to me when I run it is:



sed: unmatched '/'


I believe the reason why I'm getting this error is because in the actual sed command, I need to somehow group the range pattern altogether because I feel and in fact I've tested it, the sed command only applies to the first range, i.e. "WORD A" and then it reads the next "/" as a literal character rather than a character that encapsulates the next pattern which is WORD D.



I've tried to use single quotes and double quotes but upon running my script, I get an error saying either: sed unmatched "'" or sed unknown command.



Can someone please help resolve this issue as it's taken me two days to work this out.



Thanks!







linux sed regular-expression wildcards






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 22 at 10:38









Ahmad

1




1







  • 1




    What's the difference to your other, recent question? Same error - how did you resolve it?
    – RudiC
    Sep 22 at 10:56










  • The solution provided didn't resolve the issue. Rather, I've been able to pinpoint whats causing the issue, I just don't know how to resolve it as I've tried different ways of grouping the range
    – Ahmad
    Sep 22 at 10:59












  • 1




    What's the difference to your other, recent question? Same error - how did you resolve it?
    – RudiC
    Sep 22 at 10:56










  • The solution provided didn't resolve the issue. Rather, I've been able to pinpoint whats causing the issue, I just don't know how to resolve it as I've tried different ways of grouping the range
    – Ahmad
    Sep 22 at 10:59







1




1




What's the difference to your other, recent question? Same error - how did you resolve it?
– RudiC
Sep 22 at 10:56




What's the difference to your other, recent question? Same error - how did you resolve it?
– RudiC
Sep 22 at 10:56












The solution provided didn't resolve the issue. Rather, I've been able to pinpoint whats causing the issue, I just don't know how to resolve it as I've tried different ways of grouping the range
– Ahmad
Sep 22 at 10:59




The solution provided didn't resolve the issue. Rather, I've been able to pinpoint whats causing the issue, I just don't know how to resolve it as I've tried different ways of grouping the range
– Ahmad
Sep 22 at 10:59















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f470688%2fhow-to-implement-sed-range-pattern-command-on-groovy-script%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f470688%2fhow-to-implement-sed-range-pattern-command-on-groovy-script%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?