Hongyi Zhao <hongyi.z...@gmail.com> writes: > Hi, > > I have a lot of files which resides under a directory, and I want to > resive all of the content "([^/]+)$" in these files into '([^/]+)$'. > > I have tried with sed/xargs, but it seems so difficult for dealing with > the \ , is there any convinent method to to this job with python? > > Regards
It isn't that difficult with sed, only you have to chose a different character than / in the substitute command, one that is not present in both texts, e.g instead of s/a/b/ use s=a=b=. And then the special characters " ' () [ and $ must be escaped for the shell, and [ and $ also for the regexp. Then it comes down to sed -e s=\"\(\\[^/]+\)\\$\"=\'\(\[^/]+\)\$\'= file -- Pieter van Oostrum WWW: http://pieter.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list