tools4j/unix4j

unix4j.sed How to replace with variables

Closed this issue · 1 comments

I was looking for an equivalent of

sed "/s/abc/$vers/" file.txt

where $vers holds some value. I have a variable defined & assigned value, but it doesn't get replaced as expected.

String matched = Unix4j.grep("^COND", file).sed(Sed.Options.s, "abc" , "version").toStringResult();
where version is a variable. resultant string always contain version & not the value it holds!
Could you help?

Have you tried removing the quotes from version? Should work if version is a Java variable in your code.