-1

I’m trying to correct some errors of a file with the following input:

"[""test""]"

And I want to get this output:

["teste"]

I already tried the following commands:

sed -i s/"["/[/g *.csv
sed -i s/"]"/]/g *.csv

I get this error message:

sed: -e expressou-me #1, character 7: Command `s' umfinished (s/// - mísseis delimitator)

Can someone please help me?

AP.
  • 8,082
  • 2
  • 24
  • 33
Jojo
  • 15
  • 2

2 Answers2

0

You have to escape [ as it stands for the bracket expression opening in POSIX BRE. The closing bracket ] can be left unescaped if it appears first (see point 1 in the standard quoted above).

sed -i 's/"\["/[/g; s/"]"/]/g' file
randomir
  • 17,989
  • 1
  • 40
  • 55
0

You can try this one

sed 's/"//g;s/[a-z]\{1,\}/\"&e"/'
ctac_
  • 2,413
  • 2
  • 7
  • 17