In the afternoon, I had to change some HTML images from PNG to GIF. There are about 20. If you change one by one, it is really annoying. The automation should be automated.
When thinking about how to scripted this problem, I think there is a key point in this demand: the need to modify the original file, rather than passing it in the pipeline. Ask the Google guru and ask man sed again. The answer is displayed.
1. Use the print function of sed to check before performing replacement.
$ Sed-n'/. PNG/P' C *. htm
2. If there is no problem, replace it.
$ Sed-I's/. PNG/. gif/'C *. htm
3. If you want to make a backup before performing replacement (add the. Bak extension after the original file)
$ Sed-I. Bak's/. PNG/. gif/'c2.htm
After Evernote is used, many of my instant scripts can be recorded. This is equivalent to a buffer zone, which first exists in the buffer zone and then blogs it out.
In the future, there will be a lot of small-space blogs to record these handy little scripts.