sed删除指定行开始后所有空行

2025-05-09 09:23:09
推荐回答(1个)
回答1:

一开头的两行空行你要保留,那么就应该从第三行开始处理。
预览版:
sed '3,${/^$/d}' ./test.txt

生效版:
sed -i '3,${/^$/d}' ./test.txt