linux 中如何删除文件开头的空行

 

001、

root@PC1:/home/test2# ls
a.txt
root@PC1:/home/test2# cat a.txt


3 w e

1 e d
root@PC1:/home/test2# cat -A a.txt
$
$
3 w e$
$
1 e d$
root@PC1:/home/test2# awk 'BEGIN{i = 0} {if($0 != "") i++; if(i != 0) {print $0}}' a.txt   ## 删除文件开头的空行
3 w e

1 e d

 

posted @ 2022-06-20 11:55  小鲨鱼2018  阅读(162)  评论(0编辑  收藏  举报