1.使用sed结合grep过滤掉file中所有带有#的行
sed 's/#/\n#/g' filename | grep -v '#' | sed '/^$/d'
2.使用grep
grep ^\[^#\] filename
配合输出功能导出文件
grep ^\[^#\] httpd.conf > new-httpd.conf
根据需要替换红色部分的内容
本文共 220 字,大约阅读时间需要 1 分钟。
1.使用sed结合grep过滤掉file中所有带有#的行
sed 's/#/\n#/g' filename | grep -v '#' | sed '/^$/d'
2.使用grep
grep ^\[^#\] filename
配合输出功能导出文件
grep ^\[^#\] httpd.conf > new-httpd.conf
根据需要替换红色部分的内容
转载于:https://blog.51cto.com/moneypy/667101