hari
hari

Reputation: 11

Replace "[ with [ using shell script

while fetching the data using API, Json response file is created. but it is not standARD Json. file format We are getting extra double quote in ResponsejSON VARIABLE.

"Status":"S","Message":"Success","ResponseJson":**"**[{ 

so how to remove single double qoute.

Upvotes: 1

Views: 30

Answers (1)

DBSand
DBSand

Reputation: 750

Tried using the sed command on the whole string you provided and was able to replace using the below commands, essentially, we need to escape the special characters while using sed to substitute. Assuming you have these patterns on stored in a file, run the below and to escape all the special characters (*,",[) add a \ preceding it. for ex: * becomes \* .

given: "Status":"S","Message":"Success","ResponseJson":**"**[{ 
command: sed 's/\*\*\"\*\*\[/\[/g' test.txt
output: "Status":"S","Message":"Success","ResponseJson":[{

given: "[
command: sed 's/\"\[/\[/g' test.txt
Output: [




Upvotes: 1

Related Questions