标签:文件内容 containe meta its block test font TE ace
批量修改文件内容一般使用sed,但是在插入多行内容和不同格式的时候就遇到困难了,今天终于知道怎么处理了,记录一下!
在一个文件里包含image: 192.168.30.60的行下插入以下内容。
resources:
requests:
memory: "768Mi"
limits:
memory: "768Mi"
变更前:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: bi-web
spec:
replicas: 1
template:
metadata:
labels:
app: bi-web
spec:
containers:
- name: bi-web
image: 192.168.30.60:1179/test100/bi-web
ports:
- containerPort: 8080
命令:sed -i ‘/image: 192.168.30.60/a\ resources:\n requests:\n memory: "768Mi"\n limits:\n memory: "768Mi"‘ deploy.yml
变更后:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: bi-web
spec:
replicas: 1
template:
metadata:
labels:
app: bi-web
spec:
containers:
- name: bi-web
image: 192.168.30.60:1179/test100/bi-web
resources:
requests:
memory: "768Mi"
limits:
memory: "768Mi"
标签:文件内容 containe meta its block test font TE ace
原文地址:https://www.cnblogs.com/elisun/p/9122774.html