Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NO match word and perform find and replace in sed #61

Closed
ianirudhrawat opened this issue Feb 4, 2019 · 2 comments
Closed

NO match word and perform find and replace in sed #61

ianirudhrawat opened this issue Feb 4, 2019 · 2 comments

Comments

@ianirudhrawat
Copy link

there is Exception when we try " match word and perform find and replace ".
Eg. sed "/^hello/s/tom/jerry/g" gives "invalid sed arguments" exception .
its a functionality supported in sed

@benjwarner
Copy link
Member

benjwarner commented Feb 5, 2019

Hi there Ian,
Unfortunately the (unix4j) sed command doesn't support sequential sed commands. e.g. a search followed by a search/replace.

Another approach might be:

System.out.println(Unix4j.fromString(input)
        .grep(Grep.Options.v, "hello")
        .sed("s/tom/jerry/g")
        .toStringResult());

Cheers,
Ben

@ianirudhrawat
Copy link
Author

thanks Ben , will try that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants