How to implement sed range pattern command on groovy script
Clash 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!
linux sed regular-expression wildcards
add a comment |Â
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!
linux sed regular-expression wildcards
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
add a comment |Â
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!
linux sed regular-expression wildcards
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
linux sed regular-expression wildcards
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
add a comment |Â
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
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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