如何使用 sed 从文件中删除从已知行开始的所有行
此命令将查找以 volumes: 开头的行,并从文件中删除该行之后的所有行(包括以 volumes: 开头的行本身)。
remove_lines_from_volumes.sh
sed -i -e '/^volumes:/,$d' myfileremove_lines_from_volumes.sh
sed -i -e '/^volumes:/,$d' myfile此命令就地编辑文件(-i),不会创建文件的副本(或备份)。
Check out similar posts by category:
Linux
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow