sed 替换
sudo sed -i ’s/dapper/edgy/g’ /etc/apt/sources.list
替换 sources.list 中所有 dapper 为 edgy
-i edit files in place (makes backup if extension supplied)
’s/a/b/g’ 替换 a 为 b,g 正则全局。
find /etc/apt/ -type f -exec sed -i ’s/dapper/edgy/g’ {} +
查找 /etc/apt/ 下所有 f类型文件,执行 sed 替换。
find -type 参数:
b block (buffered) special
c character (unbuffered) special
d directory
p named pipe (FIFO)
f regular file
l symbolic link; this is never true if the -L option or the -follow option is in effect, unless the
symbolic link is broken. If you want to search for symbolic links when -L is in effect, use
-xtype.
s socket
D door (Solaris)
find /etc/apt/ -type f -exec sed -i.bak ’s/dapper/edgy/g’ {} ;
产生备份文件
info sed
查看 sed 帮助信息