디렉터리에 있는 여러 파일의 복잡한 문자열을 바꿔야 합니다.
교체해야 할 문자열은 다음과 같습니다.
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++dGAbFvZAoTvEmlwZxKsoTtb7Tulq3CR9RfCI64T64qSjlUugSbz41o9DLlOQq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z4r2BTTLzMy5/PAWOyBHWaPzV+pRrIK0+Zkz3Ypym4SGAcaaOB2K3TL1AF1i+E3kTQOKb2XMbpbfLtyGZKfqtr9NlwwUxtcVGdr5ICiSbyjykZTcoEYWPgWKVLewXKsNDqmMwfENNt7dSp8qK0fr/JEMgrIpN5u728WRhFgphKXxq7WR2zTeN7qSPru2usezUkhNaMV1Wak6bimvQY3hQ9ny6XTlZGbNrwaVxjMFNgwvtcFlcfVlawGdry6wyerdYia8fJcbexvLkxibXEm9+UOx7lSUyab4ALPECYtiUXCw8HP8EM3bxDEulyspAb5sxyVOVv046sVtFHdt4khCzHb9lsfFH23WeG5WCLIlgMyYRH6p2DB1+cMLa1PQR7PpYmxaQejaQSX+JSul2tjcRy1loy3MSuftVq36OJHIy4+Kw974GBydei1UtwVloim+3y3L2VNE/ML4Z1ZfFs8iFrGIRSxi/6/9C8Ubb5YmcgHHAAAAAElFTkSuQmCC
그리고:./logo.jpg
교체해야 하는 문자열의 다양한 특수 문자로 인해 교체를 수행하기 위해 sed를 사용하는 데 다양한 문제가 있습니다.
답변1
정규 표현식은 어떻습니까?
sed -r -i 's/(data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQoAAAAkCAAAAABUcSvnAAAHbklEQVRo3u2Ya0xURxTHR9Yt6CJdLSU0hFoxPhIS41ujDex).*(HHAAAAAElFTkSuQmCC)/.\/logo.jpg/g' filename
문자열의 시작과 끝을 찾아 .\/logo.jpg
in 으로 바꿉니다 filename
.
-i
파일 이름의 내용을 바꾸는 데 사용됩니다 .