Com o GNU sed:
sed 's|\x22\x27|\x27|;s|\x27\x22|\x27|' file
Saída:
'this text' "that text" 'other_text'
Veja: link
Por exemplo, eu quero mudar
"'this text'"
"that text"
'other_text'
em
'this text'
"that text"
'other_text'
Eu tentei
sed -e 's/^"\'/"/g'
mas minha citação deve estar desativada.
Ubuntu.
Com o GNU sed:
sed 's|\x22\x27|\x27|;s|\x27\x22|\x27|' file
Saída:
'this text' "that text" 'other_text'
Veja: link
Você não pode usar o escape \ em uma citação '' . Portanto, coloque tudo em uma cota "" e escape da " s. por exemplo. "s/^\"'/'/g"
Alternativamente, termine o '' quote, faça um \' e, em seguida, inicie novamente o '' quote, e. 's/^"'\''/'\''/g'
Além disso, se você se confundir facilmente com \'s and / s, then note you do not have to use . Você pode usar qualquer caractere, por exemplo "s%^\"'%'%g"
Isso só faz a primeira citação no início da linha, o bit que você parece estar sofrendo.
Experimente esta linha
sed -e "s/^\"'/\'/g" -e "s/'\"$/\'/g" file
Em vez de colocar a expressão sed entre ' ' , faça entre " " para poder escapar com \ o " "
por exemplo,
@tachomi:~$ echo "\"'this text'\""
"'this text'"
@tachomi:~$ echo "\"'this text'\"" | sed -e "s/^\"'/\'/g" -e "s/'\"$/\'/g"
'this text'
por exemplo,
@tachomi:~$ cat file.txt
"'this text'"
"that text"
'other_text'
@tachomi:~$ sed -e "s/^\"'/\'/g" -e "s/'\"$/\'/g" file.txt
'this text'
"that text"
'other_text'