substitui a cadeia de texto complexa em vários arquivos que contém caracteres especiais

1

Eu preciso substituir uma string complexa em vários arquivos em um diretório.

A string que precisa ser substituída é:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQoAAAAkCAAAAABUcSvnAAAHbklEQVRo3u2Ya0xURxTHR9Yt6CJdLSU0hFoxPhIS41ujDex+MATdaLElpS3EVCtpaqNVjEYqgoY0SI2iranBR03aoHW7TROrtkq6rWJFm6rhYdUgGjE2xLdZWUTgds45c+c+9oFYsF/2JMw9e+ec/5z5cR8zl7GIRSxiEYtY39pg58LCwsJlGYNNfm9t0nuYGh8u5j/I951Nb0ary4mGX/QD3ZkNtx76/f5HdxqmGPwjFFMxAoLS0a+UQh6Px8WzPdLY2JOtDzC1ZT7bxyNOejxlkLqvWdg+xmbUqfLTWGyFKOjDqFyev55RC+F1Hk9FCk+1OIR4jmW6qtKszShlL/UW2VjU7DpRbRyTkc1HKnISooKgcCjCFsMvch3getUOpdjgq16jjQcVo3vOLCTDFfa1dL1SpnGoTt7L2E8ypop9rrq+UcXYW2xIvTKSj+RTYxwObSDVhl5RT5Wy12Tkdl1NIJMeDsUZ/mMUuR+oKNrOt0kUt4Uv5WZIFO0GoSsGFChzuc0wH2WBEYU2FMVcPnSbtx8FQ6EUqYPiPyYIihk69th9qAZ9AwqcbVAUP/O/xwPkdNarKGpH1EoUW4UPAd3QrOJBVZSQpAphh4X5fH5w/D4fyYyqlfPBiA0kf/8Et636oShmU+JJGMqMAlMPE4o/J+yQKM6DjHFCExZrKBKzJIpljZAKmUdDocCrIZmxOTSzgyoKKqHY0EJAzQPe7NLuojmq0DH1/nKojiZDbU2rdiV4RQ3mmBIayozi+jW4Ypg4s7SpqWmpHMY0ITaN91YJ3yFROHAMyD8WCgW7S4oFNLOLWn15RUVFaQIC+RBQ8r2YyDlKKFCFXoHmnUAUkJpH0/yKBghEoYsJjsJbSHcCnRmelpY2PCQKO++dGAbFvZAoTvEmlwZxKsoTtb7Tulq3CR9RfCI64T64q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SuCPDTkVgd+B/zpro3z4r2BTTLzMy5/PAWOyBHWaPzV+pRrIK0+Zkz3Ypym4SGAcaaOB2K3TL1AF1i+E3kTQOKb2XMbpbfLtyGZKfqtr9NlwwUxtcVGdr5ICiSbyjykZTcoEYWPgWKVLewXKsNDqmMwfENNt7dSp8qK0fr/JEMgrIpN5u728WRhFgphKXxq7WR2zTeN7qSPru2usezUkhNaMV1Wak6bimvQY3hQ9ny6XTlZGbNrwaVxjMFNgwvtcFlcfVlawGdry6wyerdYia8fJcbexvLkxibXEm9+UOx7lSUyab4ALPECYtiUXCw8HP8EM3bxDEulyspAb5sxyVOVv046sVtFHdt4khCzHb9lsfFH23WeG5WCLIlgMyYRH6p2DB1+cMLa1PQR7PpYmxaQejaQSX+JSul2tjcRy1loy3MSuftVq36OJHIy4+Kw974GBydei1UtwVloim+3y3L2VNE/ML4Z1ZfFs8iFrGIRSxi/6/9C8Ubb5YmcgHHAAAAAElFTkSuQmCC

Com: ./logo.jpg

Estou tendo todos os tipos de problemas usando sed para a substituição devido aos vários caracteres especiais na string que precisam ser substituídos.

    
por schwach 07.12.2014 / 12:23

1 resposta

0

Que tal uma expressão regular:

sed -r -i 's/(data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQoAAAAkCAAAAABUcSvnAAAHbklEQVRo3u2Ya0xURxTHR9Yt6CJdLSU0hFoxPhIS41ujDex).*(HHAAAAAElFTkSuQmCC)/.\/logo.jpg/g' filename

Procure o início e o final da string e substitua por .\/logo.jpg in filename .

Use -i para substituir o conteúdo no nome do arquivo.

    
por 07.12.2014 / 13:27