如何用sed提取每一行的第一个字段

2025-04-24 23:23:35
推荐回答(2个)
回答1:

亲,这个用awk更为合适。

假设字段之间为空格或TAB分隔:

awk '{print $1}' myfile.txt

回答2:

sed -r 's#(.)(.*)#\1#g'