首页 > 解决方案 > sed:如何在非空行上添加到行首

问题描述

我在一个文本文件中有多行,有些是空的。

hasjdh lashd 

aksl asldh l lasjdh 

我想将 * 添加到所有非空行的开头。

*hasjdh lashd 

*aksl asldh l lasjdh 

怎么做

标签: sed

解决方案


$ sed 's/^./*&/' file
*hasjdh lashd

*aksl asldh l lasjdh

推荐阅读