Andy McRae
Andy McRae

Reputation: 667

SED - "Filename too long" on a variable

i am trying to modify a json stored in a variable like this:

PS: (This error was kinda covered here also but I tried the same process which makes terminal quit).

#The variable has some information about a json file (around 10 keys).
infos = [{"id":512,"hostName":"PC-1","pcModel":"Dell","diskType":"Samsung:...}]
#I want to modify the key where "Win10" is written and replace it with "Ubuntu" like this
sed -i "s/Win10/Ubuntu/g" "$infos"
#Then I get the error
bash: /bin/sed: Argument list too long

Is there a way to avoid this error with sed?

Thanks

Upvotes: 1

Views: 281

Answers (1)

potong
potong

Reputation: 58430

This might work for you (GNU sed and parallel):

parallel sed -i 's/Win10/Ubuntu/g' {} ::: $infos

Will edit files in place and in parallel.

Upvotes: 1

Related Questions