You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-i extension
Edit files in-place, saving backups with the specified extension. If a zero-length extension is given, no backup will be saved. It is not recom-
mended to give a zero-length extension when in-place editing files, as you risk corruption or partial content in situations where disk space is
exhausted, etc.
PyTips 文档中的插图开始用的是七牛CDN提供的原始链接,后来绑定了自己的域名之后之前用到的地方都没改,今天想统一改一下,自然想到了用常用的批量查询和修改命令:
sed
&grep
。grep
用于查询包含'7xiijd.com1.z0.glb.clouddn.com'
的所有文件:grep '7xiijd.com1.z0.glb.clouddn.com' -R ./
其中
.ipynb_checkpoints
目录下面的所有文件不需要修改,所以应该忽略掉,man grep
可以查到排除目录的参数是--exclude-dir
,另外由于结果将用于sed
进一步修改,因此只希望返回文件名,不需要在文件中的匹配结果:网上搜到一些批量处理的命令不知道是不是抄来抄去还是因为我用的版本不同,
sed -i
会报错:最后还是自己查一下手册,
man sed
:原来
-i
参数用于指定修改文件之后备份文件的后缀名(虽然在 Git 环境下面这样做多虑了,但还是很贴心地怕用户一次修改太多东西没办法撤销),所以正确的指令应该是:查看结果:
最后删除多余的备份文件:
rm Markdowns/*.bak Tips/*.bak
。The text was updated successfully, but these errors were encountered: