Replace in file with Huge String (Argument list too long)

0

I have a file in which I want to replace a string with a huge string literal in the form "19209302","19209329" such 100 thousand of entries.

I am using sed and I get "Argument list to long" error, whereas if I use such 100 entries it works.

Here is the way I am trying to do in shell script sed "s/@devices/$devices/" active_payload.json where file has a string @device which I am trying to replace with $devices a variable holds a huge string

How can I resolve this?

Riz

Posted 2015-05-29T12:24:32.627

Reputation: 1

You can use for example awk (better GNU awk). But can you please provide example of source and target – Romeo Ninov – 2015-05-29T12:26:57.120

with what Kind of Programm do you try to search/replace ? what is the file Format of the document? – veritaS – 2015-05-29T12:27:32.630

You can save the sed script to a file and use sed -f. – choroba – 2015-05-29T12:30:03.677

@user286332 i have edited my question – Riz – 2015-05-29T12:32:55.597

Please take a look at the answer to the this post. under 4. Multiple replace operations: replace with different strings. There you will also find a Suggestion to integrate your Patterns into sed files when they are large.

– veritaS – 2015-05-29T12:44:32.773

No answers