方法1:xargs
使用 xargs 命令将其中的换行符都转为空格符,指定 -n1 单列输出
cat nowcoder.txt | xargs -n1
方法2:grep 匹配换行符以外的部分,. 表示除换行符以外的所有字符,然后 sed 命令将 : 符号替换为空
grep '^.' nowcoder.txt | sed 's/://g'
方法3:awk 匹配
awk '/^./' nowcoder.txt
这里不指定 {print NR} 则显示的是内容。
方法四:sed 匹配
sed -n '/^./p' nowcoder.txt
注意:如果是要显示行号的话,则使用 sed -n '/^./=' nowcoder.txt ,显示内容的话使用参数 p。

 京公网安备 11010502036488号
京公网安备 11010502036488号